Bug 64301 - [1.5] Cast required where no cast should be required
Summary: [1.5] Cast required where no cast should be required
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-27 06:09 EDT by Stefan Matthias Aust CLA
Modified: 2005-01-11 11:02 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Matthias Aust CLA 2004-05-27 06:09:35 EDT
M9+latest 1_5 from CVS

Create two classes shown below in two compilation units.  I get an error for
"n.a.get(1).e(this)".  Cheetah can't infer that the result of get(1) should be
an N object.  If I put both classes into one compilation unit, it works. Using
an explicit cast "((N) n.a.get(1)).e(this)" also works.

----
import java.util.List;

class N {
	List<N> a;
	void e(Q q) {}
}
----
class Q {
	void e(N n) {
		n.a.get(1).e(this);
	}
}
Comment 1 Stefan Matthias Aust CLA 2004-05-27 06:14:57 EDT
This raises a warning and shouldn't. Probably related to the above problem.

class Q2 {
	void e2(N n) {
		Iterator<N> i = n.a.iterator();
	}
}
Comment 2 Philipe Mulet CLA 2004-05-27 07:02:32 EDT
This only occurs in editor, not when building. The reason is that the 
JavaModel the editor relies upon is not fully aware yet of generics. I added 
recently support for type parameters of type, to get basic things working, but 
did not change type names to type signatures. Therefore, the model doesn't 
record the fact the signature of field 'a' is List<N>, and simply considers it 
to be raw type 'List'. Hence, it fools the compiler.

When building though, the compiler is directly using the source/binaries, and 
thus doesn't get in trouble.
Comment 3 Philipe Mulet CLA 2004-06-02 12:36:37 EDT
Support added in JavaModel (SourceTypeConverter is now able to recreate 
parameterized type references). 
Comment 4 Philipe Mulet CLA 2004-06-02 12:36:59 EDT
Fixed