| Summary: | [inline] Inline Local Variable does not qualify accesses to shadowed fields | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Max Schaefer <max.schaefer> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert, deepakazad, reprogrammer |
| Version: | 3.8 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
*** This bug has been marked as a duplicate of bug 367536 *** |
Build Identifier: M20110909-1335 Consider the following program: public class A { int f = 42; int foo() { int r = f; int f = 23; return r; } public static void main(String[] args) { System.out.println(new A().foo()); } } This program prints "42". Note that the reference to field "f" in the initialiser of local variable "r" is shadowed later on by the local variable "f". Inlining local variable "r" yields the following program: public class A { int f = 42; int foo() { int f = 23; return f; // should be "return this.f;" } public static void main(String[] args) { System.out.println(new A().foo()); } } This is wrong: the program now prints "23", since the reference "f" now refers to the local variable. Reproducible: Always Steps to Reproduce: See above description.