Bug 169049 - [1.5][compiler] Bogus bound mismatch errors
Summary: [1.5][compiler] Bogus bound mismatch errors
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-25 14:57 EST by Ed Merks CLA
Modified: 2008-01-24 06:59 EST (History)
3 users (show)

See Also:
philippe_mulet: pmc_approved+


Attachments
Project containing the sample (8.39 KB, application/zip)
2006-12-25 14:58 EST, Ed Merks CLA
no flags Details
Proposed patch (10.94 KB, patch)
2007-09-14 09:19 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Merks CLA 2006-12-25 14:57:36 EST
I'll attach a sample project with what appear to be bogus bound mismatch errors. There are also big differences between the results reported by the Eclipse compiler verse the javac compiler for these examples.

For Container, Eclipse reports errors for function "f"'s "b", "d", and "g" parameters as having errors; javac reports errors for the "f" and "g" parameters.  I believe eclipse is right and that javac missed "b" and "d".

In Container2, Eclipse reports errors for function "f"'s "b", "d" and "f" parameters as having errors but the error for parameter "f" appears bogus; javac reports only the bogus error for "f" but neither of the other correct ones.

In Container3, Eclipse reports errors for function "g"'s "b", "d", "f", "g", and "j" but the error for parameter "f" appears bogus; javac reports errors for "f", "g", "i" and "j" so is reporting the same bogus "f" and another bogus "i" while missing "b" and "d".

Also in Container3, Eclipse reports errors for function "h"'s "b", "d", "f", "g", "i", and "j" parameters where "f" and "i" appear to be bogus; javac reports errors only for "f", "g", and "i", and "j", so again missing "b" and "d" and reporting the same bogus "f" and "i".

It would help me a great deal defining my Ecore constraints on the generics support in Ecore if I can be sure which behavior is correct (and why)...
Comment 1 Ed Merks CLA 2006-12-25 14:58:34 EST
Created attachment 56175 [details]
Project containing the sample
Comment 2 Olivier Thomann CLA 2006-12-26 09:34:32 EST
Could you please specify the Eclipse build id?
Comment 3 Ed Merks CLA 2006-12-26 09:52:58 EST
I'm using 3.3M4, i.e., Build id: I20061214-1445.
For javac I'm using
$ "/cygdrive/c/Program Files/IBM/Java50/bin/javac"  -version
javac 1.5.0
Comment 4 Philipe Mulet CLA 2007-09-14 07:28:21 EDT
Re: comment 0
> For Container, Eclipse reports errors for function "f"'s "b", "d", and "g"
> parameters as having errors; javac reports errors for the "f" and "g"
> parameters.  I believe eclipse is right and that javac missed "b" and "d".

In the light of bug 202404, I believe eclipse was wrong there as well for 'b' and 'd'. Note that I do not see eclipse (3.3) reporting an error against 'f'; 
Comment 5 Philipe Mulet CLA 2007-09-14 09:08:59 EDT
I think the fix for bug 104649 is responsible for the missing diagnosis on 'f'.
Reverting the fix as it is no longer needed to address bug 104649 (i.e. the fix was wrong, and other changes - likely for bug 202404 did address the original problem).
Comment 6 Philipe Mulet CLA 2007-09-14 09:19:06 EDT
Created attachment 78424 [details]
Proposed patch
Comment 7 Philipe Mulet CLA 2007-09-14 09:19:53 EDT
Added GenericTypeTest#test1168-1170
Released for 3.4M2.
Fixed
Comment 8 Philipe Mulet CLA 2007-09-14 13:14:36 EDT
Reopening. My fix breaks the following testcase:
import java.util.List;

public class X {
	static <U extends List<U>> U foo(U u) {
		List<U> v = null;
		foo(v);
		return u;
	}
}

----------
	foo(v);
	^^^
Bound mismatch: The generic method foo(U) of type X is not applicable for the arguments (List<U>). The inferred type List<U> is not a valid substitute for the bounded parameter <U extends List<U>>
----------
Comment 9 Philipe Mulet CLA 2007-09-20 08:00:33 EDT
Actually, the previous test change is actually expected.
Closing as fixed.
But only released for 3.4M3.

Released for 3.4M3.
Comment 10 Philipe Mulet CLA 2007-09-20 08:01:21 EDT
should backport to 3.3.2
Comment 11 Philipe Mulet CLA 2007-10-10 04:26:41 EDT
Released for 3.3.2
Fixed
Comment 12 Maxime Daniel CLA 2007-10-29 10:12:51 EDT
Checked that we are now consistent with javac (6_03 b05) for the initially provided test cases.

Verified for 3.4 M3 using build I20071029-0010.

BTW, Philippe, were the 'duplicate A and B' errors in test1170 introduced on purpose?
Comment 13 Philipe Mulet CLA 2007-10-29 12:45:58 EDT
Good catch. Fixed the test (note that it was still testing properly, since we were resilient enough).
Comment 14 Jerome Lanneluc CLA 2007-11-22 10:24:01 EST
Fix is safe, and quite important for EMF.
Comment 15 Philipe Mulet CLA 2007-11-23 09:21:20 EST
+1 for 3.3.2
Comment 16 Frederic Fusier CLA 2008-01-24 06:59:29 EST
Verified for 3.3.2 using build M20080123-0800.
I've also fixed test #1170 in R3_3_maintenance stream.