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

Bug 330754

Summary: [clean up] "Remove 'this' qualifier" erroneously removes explicit reference to containing instance within inner subclass of outer class
Product: [Eclipse Project] JDT Reporter: Matt Whitlock <eclipse>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Fix none

Description Matt Whitlock CLA 2010-11-21 12:58:52 EST
Build Identifier: I20100909-0800

public class Test {

	String label = "works";

	class Nested extends Test {
		Nested() {
			label = "broken";
		}
		@Override
		public String toString() {
			return Test.this.label; // this line gets altered by the clean up
		}
	}

	public static void main(String[] args) {
		System.out.println(new Test().new Nested());
	}

}

This example should print "works", but this bug changes the expression `Test.this.label` to `label`, which is a different reference, and the altered program prints "broken" instead.

Reproducible: Always
Comment 1 Markus Keller CLA 2010-11-25 12:28:21 EST
Created attachment 183870 [details]
Fix
Comment 2 Markus Keller CLA 2010-11-25 12:28:52 EST
Fixed in HEAD.