Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 93584 Details for
Bug 222534
[compiler] wrong field hides field warning for private fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
222534.txt (text/plain), 6.01 KB, created by
Philipe Mulet
on 2008-03-26 09:43:39 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-03-26 09:43:39 EDT
Size:
6.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java,v >retrieving revision 1.4 >diff -u -r1.4 FieldAccessTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java 28 Mar 2007 14:12:12 -0000 1.4 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java 26 Mar 2008 13:43:16 -0000 >@@ -483,6 +483,142 @@ > true, > options); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=222534 >+public void testONLY_017() { >+ Map options = getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.WARNING); >+ >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " Zork z;\n" + >+ " private static class Inner1 {\n" + >+ " private int field;\n" + >+ " }\n" + >+ " private static class Inner2 extends Inner1 {\n" + >+ " private int field;\n" + >+ " public void bar() {System.out.println(field);}\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n", >+ null, >+ true, >+ options); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=222534 >+public void testONLY_018() { >+ Map options = getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.WARNING); >+ >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " Zork z;\n" + >+ " public static int field;\n" + >+ " private static class Inner1 {\n" + >+ " private int field;\n" + >+ " }\n" + >+ " private static class Inner2 extends Inner1 {\n" + >+ " private int field;\n" + >+ " public void bar() {System.out.println(field);}\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " private int field;\n" + >+ " ^^^^^\n" + >+ "The field X.Inner1.field is hiding a field from type X\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 8)\n" + >+ " private int field;\n" + >+ " ^^^^^\n" + >+ "The field X.Inner2.field is hiding a field from type X\n" + >+ "----------\n", >+ null, >+ true, >+ options); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=222534 >+public void testONLY_019() { >+ Map options = getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.WARNING); >+ >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " Zork z;\n" + >+ " private static class Inner1 {\n" + >+ " private int field;\n" + >+ " }\n" + >+ " private static class Inner2 extends Inner1 {\n" + >+ " public void bar(int field) {System.out.println(field);}\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n", >+ null, >+ true, >+ options); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=222534 >+public void testONLY_020() { >+ Map options = getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.WARNING); >+ >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " Zork z;\n" + >+ " public static int field;\n" + >+ " private static class Inner1 {\n" + >+ " private int field;\n" + >+ " }\n" + >+ " private static class Inner2 extends Inner1 {\n" + >+ " public void bar(int field) {System.out.println(field);}\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " private int field;\n" + >+ " ^^^^^\n" + >+ "The field X.Inner1.field is hiding a field from type X\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 8)\n" + >+ " public void bar(int field) {System.out.println(field);}\n" + >+ " ^^^^^\n" + >+ "The parameter field is hiding a field from type X\n" + >+ "----------\n", >+ null, >+ true, >+ options); >+} > public static Class testClass() { > return FieldAccessTest.class; > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java,v >retrieving revision 1.86 >diff -u -r1.86 FieldDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 22 Feb 2008 09:49:36 -0000 1.86 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 26 Mar 2008 13:43:20 -0000 >@@ -158,6 +158,7 @@ > if (existingVariable instanceof FieldBinding) { > FieldBinding existingField = (FieldBinding) existingVariable; > if (existingField.original() == this.binding) break checkHidingSuperField; // keep checking outer scenario >+ if (!existingField.canBeSeenBy(declaringType, this, initializationScope)) break checkHidingSuperField; // keep checking outer scenario > } > // collision with supertype field > initializationScope.problemReporter().fieldHiding(this, existingVariable);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 222534
: 93584