Bug 64301

Summary: [1.5] Cast required where no cast should be required
Product: [Eclipse Project] JDT Reporter: Stefan Matthias Aust <sma>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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