Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 528363

Summary: Eclipse compiler resolves typename from superclass instead of template type
Product: [Eclipse Project] JDT Reporter: Bence Sipka <sipkab>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: sasikanth.bharadwaj
Version: 4.7.1a   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard: stalebug

Description Bence Sipka CLA 2017-12-09 16:33:50 EST
When a type name is referenced in the body if a class, the Eclipse compiler resolves it against the superclass' appropriate type instead of the type parameter present on the class declaration. Given the following example:

package test;

class SuperClass {
	class InnerClass {

	}
}

public class Test<InnerClass> extends SuperClass {
	InnerClass ic = new InnerClass();
}

Javac reports an error on the new InnerClass() expression.

This code compiles fine with the Eclipse Compiler for Java, although it shouldn't.

The example requires that the superclass has an inner class with the same name as the type parameter.
Comment 1 Sasikanth Bharadwaj CLA 2017-12-12 05:54:43 EST
Same behavior as far back as 4.4.1. I have a change that will change the behavior, but need to find the reference in JLS that dictates behavior in this situation before proceeding with that
Comment 2 Eclipse Genie CLA 2020-03-01 17:45:07 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.