Bug 98561

Summary: [1.5][compiler] Erroneous build error using inner class of a parameterized type
Product: [Eclipse Project] JDT Reporter: Tom Stamm <stammt>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tom Stamm CLA 2005-06-06 14:16:03 EDT
The JDT gives a bogus build error if you have a parameterized class, which
contains an abstract inner class and a method that takes an object of that type
as a parameter; and a subclass creates an instance of that inner class and calls
the method on the base class. It says that the inner class instance of not
appropriate for the parameters of the method.

The same code compiles without a problem using Sun's javac. It also built on
eclipse 3.1m6, but is failing on 3.1RC1.

Here is a simple rero case - the second class, Bar, does not compile in the JDT:

public class Foo<T>
{
	protected abstract class InnerFoo
	{
		protected abstract void doSomething();
	}
	
	protected void run( InnerFoo innerFoo )
	{
		innerFoo.doSomething();
	}
}


public class Bar extends Foo<Integer>
{
	public void go()
	{
		InnerFoo inner = new InnerFoo()
		{
			protected void doSomething()
			{
				System.out.println( "hello" );
			}
		};
		run( inner );
	}
}

The error is on the call to run():

The method run(Foo.InnerFoo) in the type Foo<Integer> is not applicable for the
arguments (Foo<Integer>.InnerFoo)
Comment 1 Olivier Thomann CLA 2005-06-07 10:23:43 EDT
Could not reproduce in latest.
Comment 2 Philipe Mulet CLA 2005-06-09 06:02:56 EDT
Got fixed along with other changes.
Added GenericTypeTest#test721.