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 34569 Details for
Bug 126564
[1.5][compiler] Inconsistent error reporting between static import and direct field access
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
126564.txt (text/plain), 6.30 KB, created by
Philipe Mulet
on 2006-02-13 09:58:46 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2006-02-13 09:58:46 EST
Size:
6.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java,v >retrieving revision 1.97 >diff -u -r1.97 CompilationUnitScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 6 Feb 2006 21:14:39 -0000 1.97 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 13 Feb 2006 15:00:07 -0000 >@@ -496,7 +496,7 @@ > // look to see if its a static field first > ReferenceBinding type = (ReferenceBinding) binding; > FieldBinding field = findField(type, name, null, true); >- if (field != null && field.isValidBinding() && field.isStatic() && field.canBeSeenBy(fPackage)) >+ if (field != null && field.isValidBinding() && field.isStatic() && field.canBeSeenBy(type, null, this)) > return field; > > // look to see if there is a static method with the same selector >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.258 >diff -u -r1.258 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 11 Feb 2006 16:27:15 -0000 1.258 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 13 Feb 2006 15:00:11 -0000 >@@ -1653,15 +1653,15 @@ > if (importBinding.isStatic() && !importBinding.onDemand) { > if (CharOperation.equals(importBinding.compoundName[importBinding.compoundName.length - 1], name)) { > if (unitScope.resolveSingleImport(importBinding) != null && importBinding.resolvedImport instanceof FieldBinding) { >- ReferenceBinding declaringClass = ((FieldBinding) importBinding.resolvedImport).declaringClass; >- if (declaringClass.canBeSeenBy(this)) { >- ImportReference importReference = importBinding.reference; >- if (importReference != null) importReference.used = true; >- invocationSite.setActualReceiverType(declaringClass); >- return importBinding.resolvedImport; >+ foundField = (FieldBinding) importBinding.resolvedImport; >+ ImportReference importReference = importBinding.reference; >+ if (importReference != null) importReference.used = true; >+ invocationSite.setActualReceiverType(foundField.declaringClass); >+ if (foundField.isValidBinding()) { >+ return foundField; > } > if (problemField == null) >- problemField = new ProblemFieldBinding(declaringClass, name, ProblemReasons.ReceiverTypeNotVisible); >+ problemField = foundField; > } > } > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java,v >retrieving revision 1.43 >diff -u -r1.43 StaticImportTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 13 Feb 2006 12:18:35 -0000 1.43 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 13 Feb 2006 15:00:13 -0000 >@@ -129,24 +129,20 @@ > }, > "" > ); >- this.runNegativeTest( >+ this.runConformTest( > new String[] { > "X.java", > "import static p.A.C;\n" + >- "public class X { int i = C; }\n", >+ "public class X { \n" + >+ " int i = C; \n" + >+ " int j = p.A.C; \n" + >+ "}\n", > "p/A.java", > "package p;\n" + > "public class A implements I {}\n" + > "interface I { public static int C = 1; }\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " public class X { int i = C; }\n" + >- " ^\n" + >- "The type I is not visible\n" + >- "----------\n" >- // C in p.I is not defined in a public class or interface; cannot be accessed from outside package >- ); >+ ""); > } > > public void test004() { // test static vs. instance >@@ -1341,7 +1337,7 @@ > ); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=126564 >- public void _test036() { >+ public void test036() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -1360,41 +1356,25 @@ > "class B { int CONSTANT_B = 1; }", > }, > "----------\n" + >- "1. ERROR in X.java (at line 1)\n" + >- " import static p.A.CONSTANT_I;\n" + >- " ^^^^^^^^^^^^^^\n" + >- "The type I is not visible\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 2)\n" + >+ "1. ERROR in X.java (at line 2)\n" + > " import static p.A.CONSTANT_B;\n" + > " ^^^^^^^^^^^^^^\n" + > "The type B is not visible\n" + > "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " static int i = p.A.CONSTANT_I;\n" + >- " ^^^^^^^^^^^^^^\n" + >- "The type I is not visible\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 5)\n" + >+ "2. ERROR in X.java (at line 5)\n" + > " static int j = p.A.CONSTANT_B;\n" + > " ^^^^^^^^^^^^^^\n" + > "The type B is not visible\n" + > "----------\n" + >- "5. ERROR in X.java (at line 6)\n" + >- " static int m = CONSTANT_I;\n" + >- " ^^^^^^^^^^\n" + >- "CONSTANT_I cannot be resolved\n" + >- "----------\n" + >- "6. ERROR in X.java (at line 7)\n" + >+ "3. ERROR in X.java (at line 7)\n" + > " static int n = CONSTANT_B;\n" + > " ^^^^^^^^^^\n" + > "CONSTANT_B cannot be resolved\n" + >- "----------\n" >- ); >+ "----------\n"); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=126564 - variation >- public void _test037() { >- this.runNegativeTest( >+ public void test037() { >+ this.runConformTest( > new String[] { > "X.java", > "import static p.A.CONSTANT_I;\n" + >@@ -1411,6 +1391,6 @@ > "interface I { int CONSTANT_I = 1; }\n" + > "class B { public static int CONSTANT_B = 1; }", > }, >- "?"); >+ ""); > } > }
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 126564
: 34569