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 124952 Details for
Bug 263877
[1.5][compiler] forward reference error flagged within enum
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
263877.txt (text/plain), 4.03 KB, created by
Philipe Mulet
on 2009-02-06 07:00:01 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2009-02-06 07:00:01 EST
Size:
4.03 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.138 >diff -u -r1.138 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 29 Jan 2009 17:00:08 -0000 1.138 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 6 Feb 2009 11:59:27 -0000 >@@ -718,8 +718,8 @@ > } > > if (field.isStatic()) { >- ReferenceBinding declaringClass = field.original().declaringClass; >- if (declaringClass.isEnum()) { >+ if ((field.modifiers & ClassFileConstants.AccEnum) != 0) { // enum constants are checked even when qualified) >+ ReferenceBinding declaringClass = field.original().declaringClass; > MethodScope methodScope = scope.methodScope(); > SourceTypeBinding sourceType = methodScope.enclosingSourceType(); > if ((this.bits & ASTNode.IsStrictlyAssigned) == 0 >@@ -928,7 +928,7 @@ > ReferenceBinding declaringClass = fieldBinding.original().declaringClass; > SourceTypeBinding sourceType = methodScope.enclosingSourceType(); > // check for forward references >- if ((this.indexOfFirstFieldBinding == 1 || declaringClass.isEnum()) >+ if ((this.indexOfFirstFieldBinding == 1 || (fieldBinding.modifiers & ClassFileConstants.AccEnum) != 0) // enum constants are checked even when qualified > && sourceType == declaringClass > && methodScope.lastVisibleFieldID >= 0 > && fieldBinding.id >= methodScope.lastVisibleFieldID >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java,v >retrieving revision 1.139 >diff -u -r1.139 EnumTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 10 Dec 2008 19:39:17 -0000 1.139 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 6 Feb 2009 11:59:29 -0000 >@@ -6105,5 +6105,42 @@ > "Cannot reference a field before it is defined\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=263877 >+public void test170() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", // ================= >+ "enum Days {\n" + >+ " Monday(\"Mon\", Days.OFFSET + 0), // should not complain\n" + >+ " Tuesday(\"Tue\", Days.Wednesday.hashCode()), // should complain since enum constant\n" + >+ " Wednesday(\"Wed\", OFFSET + 2); // should complain since unqualified\n" + >+ " public static final int OFFSET = 0; // cannot move this above, else more errors\n" + >+ " Days(String abbr, int index) {\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "class X {\n" + >+ " public static final int FOO = X.OFFSET + 0;\n" + >+ " public static final int BAR = OFFSET + 1;\n" + >+ " public static final int OFFSET = 0; // cannot move this above, else more errors\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " Tuesday(\"Tue\", Days.Wednesday.hashCode()), // should complain since enum constant\n" + >+ " ^^^^^^^^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " Wednesday(\"Wed\", OFFSET + 2); // should complain since unqualified\n" + >+ " ^^^^^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 12)\n" + >+ " public static final int BAR = OFFSET + 1;\n" + >+ " ^^^^^^\n" + >+ "Cannot reference a field before it is defined\n" + >+ "----------\n"); >+} > } >
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 263877
:
124952
|
124954
|
124955