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 172983 Details for
Bug 317858
Eclipse isn't accessing the correct field/class - causes compile error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch under consideration.
patch.txt (text/plain), 7.96 KB, created by
Srikanth Sankaran
on 2010-06-28 23:53:22 EDT
(
hide
)
Description:
Patch under consideration.
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-06-28 23:53:22 EDT
Size:
7.96 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java,v >retrieving revision 1.117 >diff -u -r1.117 BlockScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 17 Mar 2010 16:10:00 -0000 1.117 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 29 Jun 2010 03:52:19 -0000 >@@ -464,22 +464,31 @@ > problemReporter().deprecatedType(referenceBinding, invocationNode); > } > } >+ Binding problemFieldBinding = null; > while (currentIndex < length) { > referenceBinding = (ReferenceBinding) binding; > char[] nextName = compoundName[currentIndex++]; > invocationSite.setFieldIndex(currentIndex); > invocationSite.setActualReceiverType(referenceBinding); > if ((mask & Binding.FIELD) != 0 && (binding = findField(referenceBinding, nextName, invocationSite, true /*resolve*/)) != null) { >- if (!binding.isValidBinding()) { >- return new ProblemFieldBinding( >- ((ProblemFieldBinding)binding).closestMatch, >- ((ProblemFieldBinding)binding).declaringClass, >- CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'), >- binding.problemId()); >+ if (binding.isValidBinding()) { >+ break; // binding is now a field >+ } >+ problemFieldBinding = new ProblemFieldBinding( >+ ((ProblemFieldBinding)binding).closestMatch, >+ ((ProblemFieldBinding)binding).declaringClass, >+ CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'), >+ binding.problemId()); >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858 : If field is inaccessible, >+ // don't give up yet, continue to look for a visible member type >+ if (binding.problemId() != ProblemReasons.NotVisible) { >+ return problemFieldBinding; > } >- break; // binding is now a field > } > if ((binding = findMemberType(nextName, referenceBinding)) == null) { >+ if (problemFieldBinding != null) { >+ return problemFieldBinding; >+ } > if ((mask & Binding.FIELD) != 0) { > return new ProblemFieldBinding( > null, >@@ -498,11 +507,15 @@ > ProblemReasons.NotFound); > } > // binding is a ReferenceBinding >- if (!binding.isValidBinding()) >+ if (!binding.isValidBinding()) { >+ if (problemFieldBinding != null) { >+ return problemFieldBinding; >+ } > return new ProblemReferenceBinding( > CharOperation.subarray(compoundName, 0, currentIndex), > (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), > binding.problemId()); >+ } > if (invocationSite instanceof ASTNode) { > referenceBinding = (ReferenceBinding) binding; > ASTNode invocationNode = (ASTNode) invocationSite; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java,v >retrieving revision 1.84 >diff -u -r1.84 LookupTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 23 Jun 2010 06:52:41 -0000 1.84 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 29 Jun 2010 03:52:22 -0000 >@@ -3176,6 +3176,141 @@ > "The type B$A is not visible\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858 >+public void test098() { >+ this.runConformTest( >+ new String[] { >+ "B.java",//------------------------------ >+ "class A {\n" + >+ " public final static class B {\n" + >+ " public final static String length = \"very long\";\n" + >+ " }\n" + >+ " private int [] B = new int[5];\n" + >+ "}\n" + >+ "public class B {\n" + >+ " public static void main(String[] args) {\n" + >+ " System.out.println(A.B.length);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "very long"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858 >+public void test099() { >+ this.runNegativeTest( >+ new String[] { >+ "B.java",//------------------------------ >+ "class A {\n" + >+ " public final static class B {\n" + >+ " public final static String length = \"very long\";\n" + >+ " }\n" + >+ " public int [] B = new int[5];\n" + >+ "}\n" + >+ "public class B {\n" + >+ " public static void main(String[] args) {\n" + >+ " System.out.println(A.B.length);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in B.java (at line 9)\n" + >+ " System.out.println(A.B.length);\n" + >+ " ^^^^^^^^^^\n" + >+ "Cannot make a static reference to the non-static field A.B\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858 >+public void test100() { >+ this.runConformTest( >+ new String[] { >+ "B.java",//------------------------------ >+ "class A {\n" + >+ " public final class B {\n" + >+ " public final String length = \"very long\";\n" + >+ " }\n" + >+ " public static int [] B = new int[5];\n" + >+ "}\n" + >+ "public class B {\n" + >+ " public static void main(String[] args) {\n" + >+ " System.out.println(A.B.length);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "5"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858 >+public void test101() { >+ this.runNegativeTest( >+ new String[] { >+ "B.java",//------------------------------ >+ "class A {\n" + >+ " private final class B {\n" + >+ " public final String length = \"very long\";\n" + >+ " }\n" + >+ " private int [] B = new int[5];\n" + >+ "}\n" + >+ "public class B {\n" + >+ " public static void main(String[] args) {\n" + >+ " System.out.println(A.B.length);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in B.java (at line 2)\n" + >+ " private final class B {\n" + >+ " ^\n" + >+ "The type A.B is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in B.java (at line 3)\n" + >+ " public final String length = \"very long\";\n" + >+ " ^^^^^^\n" + >+ "The field A.B.length is never read locally\n" + >+ "----------\n" + >+ "3. WARNING in B.java (at line 5)\n" + >+ " private int [] B = new int[5];\n" + >+ " ^\n" + >+ "The field A.B is never read locally\n" + >+ "----------\n" + >+ "4. ERROR in B.java (at line 9)\n" + >+ " System.out.println(A.B.length);\n" + >+ " ^\n" + >+ "The field A.B is not visible\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858 >+public void test102() { >+ this.runNegativeTest( >+ new String[] { >+ "B.java",//------------------------------ >+ "class A {\n" + >+ " public final class B {\n" + >+ " private final String length = \"very long\";\n" + >+ " }\n" + >+ " private int [] B = new int[5];\n" + >+ "}\n" + >+ "public class B {\n" + >+ " public static void main(String[] args) {\n" + >+ " System.out.println(A.B.length);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in B.java (at line 3)\n" + >+ " private final String length = \"very long\";\n" + >+ " ^^^^^^\n" + >+ "The field A.B.length is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in B.java (at line 5)\n" + >+ " private int [] B = new int[5];\n" + >+ " ^\n" + >+ "The field A.B is never read locally\n" + >+ "----------\n" + >+ "3. ERROR in B.java (at line 9)\n" + >+ " System.out.println(A.B.length);\n" + >+ " ^^^^^^\n" + >+ "The field A.B.length is not visible\n" + >+ "----------\n"); >+} > public static Class testClass() { return LookupTest.class; > } > }
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 317858
: 172983