Bug 25229 - Compiler should not reject innerclass scenario
Summary: Compiler should not reject innerclass scenario
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-23 05:02 EDT by Philipe Mulet CLA
Modified: 2002-11-13 08:43 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2002-10-23 05:02:26 EDT
Build 2.1M2

The following code is rejected by the compiler complaining against the 
enclosing instance of anonymous subclass of X1. Javac accepts this code as 
expected.

=======
public class X {

	public static void main(String[] arguments) {
		new X().new X2().foo();
	}
	class X1 {
		void baz1() {
			System.out.println("X1.baz1()");
		}
	}
	class X2 {
		void foo(){
			X.this.new X1(){
				void bar(){
					baz();
					baz1();
					baz2();
				}
			}.bar();
		}	
		void baz2() {
			System.out.println("X2.baz2()");
		}
	}
	void baz() {
		System.out.println("X.baz()");
	}
}
Comment 1 Philipe Mulet CLA 2002-10-23 05:54:45 EDT
Problem was that enclosing instance was only allowed as first synthetic 
argument, where it could be anywhere amongst synthetic arguments.

Fixed
Comment 2 David Audel CLA 2002-11-13 08:43:22 EST
Verified.