This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Introduced variable shadowing a field leads to change of behavior and compile error | ||
---|---|---|---|
Product: | java | Reporter: | Jachym_Vojtek |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 8.2 | ||
Hardware: | PC | ||
OS: | Windows 7 | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 262281 | ||
Bug Blocks: |
Description
Jachym_Vojtek
2015-11-06 10:16:10 UTC
Breaks code, bumping priority. One more example class you can use for testing so that the scope qualifier of outer classes is prefixed properly. Enjoy: package pck; public class CheckFieldShadowing { int i = 9; class InnerClass extends ParentClassForShadowing { class InnerInnerClass { void foo() { // Introduce variable for 'System.currentTimeMillis()', // use names: 'x', 'y', 'z,',' i' System.out.println(System.currentTimeMillis()); System.out.println(x); System.out.println(y); System.out.println(z); System.out.println(i); } } } } class ParentClassForShadowing extends SuperParentClass implements SuperInterface { public int x; } class SuperParentClass { protected int y; } interface SuperInterface { static int z = 3; } I don't think I can fix the behaviour change without some additional metadata (the same case would be a Math.random() call assigned to a variable). But replacement of the method call statement with expression (which is not a proper statement) can be fixed. Not a P2, though. Adding dependency; I need to find the to-be-shadowed definitions. Fixed in jet-main#a494d90e587c Integrated into 'main-silver', will be available in build *201606180002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/a494d90e587c User: Svata Dedic <sdedic@netbeans.org> Log: #256404: UI warns if a symbol should be shadowed; refactors references, if the user insists on shadowing |