Bug 91061 - [1.5][compiler] Static reference to outer type variable should not be allowed
Summary: [1.5][compiler] Static reference to outer type variable should not be allowed
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-11 19:29 EDT by Tim Hanson CLA
Modified: 2005-06-10 10:18 EDT (History)
0 users

See Also:


Attachments
Proposed patch (821 bytes, patch)
2005-04-12 13:03 EDT, Tim Hanson CLA
no flags Details | Diff
Proposed Test Case (1.24 KB, patch)
2005-04-12 14:08 EDT, Tim Hanson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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