Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330754 - [clean up] "Remove 'this' qualifier" erroneously removes explicit reference to containing instance within inner subclass of outer class
Summary: [clean up] "Remove 'this' qualifier" erroneously removes explicit reference t...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-21 12:58 EST by Matt Whitlock CLA
Modified: 2010-11-25 12:28 EST (History)
0 users

See Also:


Attachments
Fix (1.95 KB, patch)
2010-11-25 12:28 EST, Markus Keller CLA
no flags Details | Diff

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