Bug 139525 - [1.5][compiler] Valid generics involved assignment is flagged as an error
Summary: [1.5][compiler] Valid generics involved assignment is flagged as an error
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.2 RC3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 139619 139669 140466 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-01 11:39 EDT by Venkatesh Prasad Ranganath CLA
Modified: 2006-05-06 13:29 EDT (History)
4 users (show)

See Also:


Attachments
JDT (compiler) preferences (5.71 KB, text/plain)
2006-05-02 02:01 EDT, Venkatesh Prasad Ranganath CLA
no flags Details
Proposed patch (5.22 KB, patch)
2006-05-02 09:14 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 Venkatesh Prasad Ranganath CLA 2006-05-01 11:39:07 EDT
In the below given test case, Eclispe java compiler reports "Type mismatch: cannot convert from Collection<IDA.Enum1> to Collection<IDA.Enum1>" error in S.java.  

Interestingly, the error does not appear when these interfaces/classes are in the same file (non-public).

ID.java:
-------
import java.util.Collection;

public interface ID {

	Collection<? extends Comparable<?>> getIds();
}

IDA.java:
--------
import java.util.Collection;

public interface IDA<T1, C1, E1, E2, C2, T2>
		extends ID {

	enum Enum1 {
		ONE, TWO
	}

	Collection<IDA.Enum1> getIds();
}

S.java:
------
import java.util.Collection;

class S {

	public static void cow(IDA<?, ?, ?, ?, ?, ?> s) {
		Collection<IDA.Enum1> ids = s.getIds();  // Error here
	}
}
Comment 1 Olivier Thomann CLA 2006-05-01 11:48:38 EDT
I just tried with 3.2RC2 and I could not reproduce.
Could you please try with RC2 and let me know if you reproduce?

I could not reproduce using 3.2RC1, 3.2M6, 3.2M4.
What is your build id?
Comment 2 Venkatesh Prasad Ranganath CLA 2006-05-01 16:09:53 EDT
The buildId is I20060428-1315.  This error was not occurring prior to 3.2RC2.
Comment 3 Olivier Thomann CLA 2006-05-01 21:42:07 EDT
I tried with the same build and I could not reproduce.
Could you please provide your compiler preferences?
Thanks.
Comment 4 Venkatesh Prasad Ranganath CLA 2006-05-02 02:01:50 EDT
Created attachment 40025 [details]
JDT (compiler) preferences 

My compiler prefrences.
Comment 5 Venkatesh Prasad Ranganath CLA 2006-05-02 02:03:55 EDT
Here is how you can reproduce it.

(I have turned on "Build Automatically" option.)

1) Create a Java project and dump the files into the project.
2) Clean the project.  The build should not show any error.
3) Now, open S.java, type an arbitrary whitespace, and save the file.  The error should appear.
Comment 6 Olivier Thomann CLA 2006-05-02 09:08:43 EDT
Reproduced using RC2.
Seems to affect the incremental compiler only. A batch compilation works fine.
Comment 7 Philipe Mulet CLA 2006-05-02 09:10:18 EDT
Reproduced, added GenericTypeTest#test0976.
This indeed is a regression introduced with fix for bug 137203.
Tuned LookupEnvironment#convertUnresolvedBinaryToRawType(...) to meet expectation.
Comment 8 Philipe Mulet CLA 2006-05-02 09:13:12 EDT
Markus: as Martin's backup, can you pls cast your vote ?
This is a regression introduced in RC2. Without it, we have an inconsistency in between the type resolved from source and binary reference, which are thus no longer comparing identical any longer. This likely is also visible in DOM AST.
Comment 9 Philipe Mulet CLA 2006-05-02 09:14:53 EDT
Created attachment 40029 [details]
Proposed patch

Patch contains the LookupEnvironment fix + regression test.
Also added a small performance change (check Object scenario which occurs frequently from what was seen during debugging - Object cannot be generic per construction).
Comment 10 Markus Keller CLA 2006-05-02 09:45:18 EDT
+1 for 3.2 RC3.
Comment 11 Philipe Mulet CLA 2006-05-02 10:01:12 EDT
*** Bug 139619 has been marked as a duplicate of this bug. ***
Comment 12 Philipe Mulet CLA 2006-05-02 10:10:29 EDT
fixed in HEAD
Comment 13 Olivier Thomann CLA 2006-05-02 10:25:07 EDT
*** Bug 139669 has been marked as a duplicate of this bug. ***
Comment 14 Olivier Thomann CLA 2006-05-03 11:09:55 EDT
Verified using N20060503-0010 for 3.2RC3
Comment 15 Frederic Fusier CLA 2006-05-04 07:47:44 EDT
Double-checked using build N20060504-0010
Comment 16 Frederic Fusier CLA 2006-05-06 13:29:22 EDT
*** Bug 140466 has been marked as a duplicate of this bug. ***