Bug 99553 - [1.5][compiler] Parameterized class nested statically inside another parameterized type causes compile errors when used in method signatures
Summary: [1.5][compiler] Parameterized class nested statically inside another paramete...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-12 21:53 EDT by Will Hains CLA
Modified: 2005-06-16 14:23 EDT (History)
1 user (show)

See Also:


Attachments
Patch for jdt/core (2.78 KB, patch)
2005-06-13 09:38 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 Will Hains CLA 2005-06-12 21:53:57 EDT
This compiles OK in both Eclipse and javac:

 1: interface TestGeneric1<A>
 2: {
 3: 	NonNested<A> getNonNested();
 4: }
 5: 
 6: class NonNested<B> implements TestGeneric1<B>
 7: {
 8: 	public NonNested<B> getNonNested()
 9: 	{
10:		return this;
11: 	}
12: }

But this doesn't compile in Eclipse, even though it compiles find in javac:

 1: interface TestGeneric2<A>
 2: {
 3: 	Nested<A> getNested();
 4: 	
 5: 	class Nested<B> implements TestGeneric2<B>
 6: 	{
 7: 		public Nested<B> getNested()
 8: 		{
 9: 			return this;
10: 		}
11: 	}
12: }

The Nested class is automatically static because it is nested in an interface, 
yet the compile errors Eclipse gives are:

Line 7: "The return type is incompatible with TestGeneric2<B>.getNested()"
Line 9: "Type mismatch: cannot convert from TestGeneric2<A>.Nested<B> to 
TestGeneric2<B>.Nested"

The reference in the error message to "TestGeneric2<A>.Nested<B>" is 
nonsensical, since Nested<B> is a static member of TestGeneric2.
Comment 1 Will Hains CLA 2005-06-12 21:55:29 EDT
(Typo - I meant to say, "...even though it compiles fine in javac")
Comment 2 Will Hains CLA 2005-06-12 21:56:54 EDT
Actually, the reference in the error message to "TestGeneric2<B>.Nested" is 
also nonsensical, for the same reason.
Comment 3 Philipe Mulet CLA 2005-06-13 07:00:14 EDT
Reproduced in RC2.
Comment 4 Philipe Mulet CLA 2005-06-13 09:07:41 EDT
We did not construct proper parameterized types in these few situations where
implicit static member types were referenced. 

We were using generic type binding in place of a parameterized type where
enclosing is a raw type.

Fix is available.

+1 for RC3

Dirk - would you please vote for it ?
Comment 5 Philipe Mulet CLA 2005-06-13 09:35:48 EDT
Added GenericTypeTest#test743
Comment 6 Philipe Mulet CLA 2005-06-13 09:38:15 EDT
Created attachment 22919 [details]
Patch for jdt/core
Comment 7 Dirk Baeumer CLA 2005-06-13 10:12:33 EDT
+1 for RC3. Is there any impact on JDT/UI you can think of ?
Comment 8 Philipe Mulet CLA 2005-06-13 10:29:07 EDT
It should only be better, as offending bindings were really misleading.
We will run your test anyway.
Comment 9 Jerome Lanneluc CLA 2005-06-13 11:46:17 EDT
JDT UI amd Refactoring tests are passing with this patch (ignoring the known 
failure for TypeRulesTest#testIsCastCompatible())
Comment 10 Philipe Mulet CLA 2005-06-13 11:53:17 EDT
Thanks Jerome. Will release to HEAD.
Comment 11 Olivier Thomann CLA 2005-06-16 14:23:16 EDT
Verified using N20050616-0010 + JDT/Core HEAD