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

Bug 91061

Summary: [1.5][compiler] Static reference to outer type variable should not be allowed
Product: [Eclipse Project] JDT Reporter: Tim Hanson <thanson>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Proposed Test Case none

Description Tim Hanson CLA 2005-04-11 19:29:41 EDT
An inner interface is implicitly static. It should not be allowed to reference
an outer classes type variable. The reference to "T" in the inner interface
below should be flagged as an error. 

class Outer<T> {
	interface Inner {
		abstract void m1(T t);
	}
}
Comment 1 Tim Hanson CLA 2005-04-12 13:03:05 EDT
Created attachment 19818 [details]
Proposed patch

The proposed patch simply marks inner interfaces as static. See JLS2 8.5.2.
Comment 2 Tim Hanson CLA 2005-04-12 14:08:10 EDT
Created attachment 19823 [details]
Proposed Test Case

Added a test to GenericTypeTest
Comment 3 Philipe Mulet CLA 2005-06-03 19:00:19 EDT
Thanks Tim.
Comment 4 Philipe Mulet CLA 2005-06-04 09:14:57 EDT
Without any change, we already detect:

public class X<T> {
	interface Y {
		java.util.List<T> lt;
	}
}

The suggested fix is adding a static modifier to member interfaces which I
believe we would need to clear at some later point. Would prefer another approach.
Comment 5 Philipe Mulet CLA 2005-06-04 15:57:27 EDT
Fixed by using isStatic() in place of bit check in Scope#getTypeOrPackage(...).
Added GenericTypeTest#test713

Fixed
Comment 6 Olivier Thomann CLA 2005-06-06 21:05:13 EDT
Verified in N20050606-0010 + JDT/Core HEAD
Comment 7 Jerome Lanneluc CLA 2005-06-10 10:18:29 EDT
Verified with I20050610-010