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 54349 Details for
Bug 165291
[1.5] Missing diagnosis for illegal forward field ref in generics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
165291.txt (text/plain), 5.83 KB, created by
Philipe Mulet
on 2006-11-22 13:03:33 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2006-11-22 13:03:33 EST
Size:
5.83 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v >retrieving revision 1.109 >diff -u -r1.109 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 8 Nov 2006 04:03:21 -0000 1.109 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 22 Nov 2006 17:56:26 -0000 >@@ -294,7 +294,7 @@ > MethodScope methodScope = scope.methodScope(); > // check for forward references > if (this.indexOfFirstFieldBinding == 1 >- && methodScope.enclosingSourceType() == fieldBinding.declaringClass >+ && methodScope.enclosingSourceType() == fieldBinding.original().declaringClass > && methodScope.lastVisibleFieldID >= 0 > && fieldBinding.id >= methodScope.lastVisibleFieldID > && (!fieldBinding.isStatic() || methodScope.isStatic)) { >@@ -999,10 +999,9 @@ > if (binding instanceof FieldBinding) { > FieldBinding fieldBinding = (FieldBinding) binding; > MethodScope methodScope = scope.methodScope(); >- ReferenceBinding declaringClass = fieldBinding.declaringClass; > // check for forward references > if (this.indexOfFirstFieldBinding == 1 >- && methodScope.enclosingSourceType() == declaringClass >+ && methodScope.enclosingSourceType() == fieldBinding.original().declaringClass > && methodScope.lastVisibleFieldID >= 0 > && fieldBinding.id >= methodScope.lastVisibleFieldID > && (!fieldBinding.isStatic() || methodScope.isStatic)) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.91 >diff -u -r1.91 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 13 Oct 2006 19:20:46 -0000 1.91 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 22 Nov 2006 17:56:26 -0000 >@@ -197,15 +197,12 @@ > scope.problemReporter().deprecatedField(fieldBinding, this); > > if ((this.bits & IsStrictlyAssigned) == 0 >- && methodScope.enclosingSourceType() == fieldBinding.declaringClass >- && methodScope.lastVisibleFieldID >= 0 >- && fieldBinding.id >= methodScope.lastVisibleFieldID) { >- //if the field is static and ms is not .... then it is valid >- if (!fieldBinding.isStatic() || methodScope.isStatic) >- scope.problemReporter().forwardReference(this, 0, methodScope.enclosingSourceType()); >+ && methodScope.enclosingSourceType() == fieldBinding.original().declaringClass >+ && methodScope.lastVisibleFieldID >= 0 >+ && fieldBinding.id >= methodScope.lastVisibleFieldID >+ && (!fieldBinding.isStatic() || methodScope.isStatic)) { >+ scope.problemReporter().forwardReference(this, 0, methodScope.enclosingSourceType()); > } >- //==================================================== >- > return fieldBinding.type; > > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.563 >diff -u -r1.563 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 22 Nov 2006 16:53:59 -0000 1.563 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 22 Nov 2006 17:56:38 -0000 >@@ -35664,4 +35664,68 @@ > }, > "ERR"); > } >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=165291 >+public void test1085() { >+ this.runNegativeTest( >+ new String[] { >+ "Y.java", >+ "class Z {\n" + >+ " Z z1 = z1;\n" + >+ " Z[] z2 = z2;\n" + >+ "}\n" + >+ "public class Y<E> {\n" + >+ " E e0 = es[0];\n" + >+ " E e = e;\n" + >+ " E[] es = es;\n" + >+ " E e2 = e2.e;\n" + >+ "}", // =================, >+ }, >+ "----------\n" + >+ "1. WARNING in Y.java (at line 2)\n" + >+ " Z z1 = z1;\n" + >+ " ^^^^^^^\n" + >+ "The assignment to variable z1 has no effect\n" + >+ "----------\n" + >+ "2. ERROR in Y.java (at line 2)\n" + >+ " Z z1 = z1;\n" + >+ " ^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "3. WARNING in Y.java (at line 3)\n" + >+ " Z[] z2 = z2;\n" + >+ " ^^^^^^^\n" + >+ "The assignment to variable z2 has no effect\n" + >+ "----------\n" + >+ "4. ERROR in Y.java (at line 3)\n" + >+ " Z[] z2 = z2;\n" + >+ " ^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "5. ERROR in Y.java (at line 6)\n" + >+ " E e0 = es[0];\n" + >+ " ^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "6. ERROR in Y.java (at line 7)\n" + >+ " E e = e;\n" + >+ " ^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "7. ERROR in Y.java (at line 8)\n" + >+ " E[] es = es;\n" + >+ " ^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "8. ERROR in Y.java (at line 9)\n" + >+ " E e2 = e2.e;\n" + >+ " ^^^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "9. ERROR in Y.java (at line 9)\n" + >+ " E e2 = e2.e;\n" + >+ " ^^^^\n" + >+ "e2.e cannot be resolved or is not a field\n" + >+ "----------\n"); >+} > } >\ No newline at end of file
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 165291
: 54349