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 115681 Details for
Bug 251523
[1.5][compiler] Should still flag Enum#valueOf override
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
251523.txt (text/plain), 3.65 KB, created by
Philipe Mulet
on 2008-10-21 08:25:05 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-10-21 08:25:05 EDT
Size:
3.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.166 >diff -u -r1.166 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 17 Oct 2008 18:07:19 -0000 1.166 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 21 Oct 2008 12:24:40 -0000 >@@ -1163,16 +1163,22 @@ > } else if (!method.areParametersEqual(method2)) { // prior to 1.5, parameter identity meant a collision case > continue nextSibling; > } >- boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES)); > // report duplicate >- AbstractMethodDeclaration method2Decl = method2.sourceMethod(); >- if (method2Decl != null && method2Decl.binding != null) { // ensure its a valid user defined method >+ AbstractMethodDeclaration methodToBlame = method2.sourceMethod(); >+ if (methodToBlame == null) { // if method2 is synthetic (like enum#valueOf) blame it on first method instead >+ if (methodDecl == null) { >+ methodDecl = method.sourceMethod(); >+ } >+ methodToBlame = methodDecl; >+ } >+ if (methodToBlame != null && methodToBlame.binding != null) { // ensure its a valid user defined method >+ boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES)); > if (isEnumSpecialMethod) { >- this.scope.problemReporter().duplicateEnumSpecialMethod(this, method2Decl); >+ this.scope.problemReporter().duplicateEnumSpecialMethod(this, methodToBlame); > } else { >- this.scope.problemReporter().duplicateMethodInType(this, method2Decl, method.areParametersEqual(method2)); >+ this.scope.problemReporter().duplicateMethodInType(this, methodToBlame, method.areParametersEqual(method2)); > } >- method2Decl.binding = null; >+ methodToBlame.binding = null; > // do not alter original method array until resolution is over, due to reentrance (143259) > if (resolvedMethods == this.methods) > System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length); >#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.131 >diff -u -r1.131 EnumTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 17 Oct 2008 18:07:27 -0000 1.131 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 21 Oct 2008 12:24:42 -0000 >@@ -5683,4 +5683,21 @@ > }, > ""); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239225 - variation >+public void test164() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", // ================= >+ "public enum X {\n" + >+ " ;\n" + >+ " private X valueOf(String arg0) { return null; }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " private X valueOf(String arg0) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "The enum X already defines the method valueOf(String) implicitly\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 251523
:
115681
|
115694