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 49701 Details for
Bug 156591
[1.5][compiler] constant-specific methods in enum cannot be abstract
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
156591.txt (text/plain), 4.78 KB, created by
Philipe Mulet
on 2006-09-08 06:05:40 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2006-09-08 06:05:40 EDT
Size:
4.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.108 >diff -u -r1.108 EnumTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 8 Sep 2006 01:09:16 -0000 1.108 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 8 Sep 2006 10:08:27 -0000 >@@ -4875,4 +4875,72 @@ > }, > "0"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156591 >+public void test138() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public enum X {\n" + >+ " PLUS {\n" + >+ " double eval(double x, double y) {\n" + >+ " return x + y;\n" + >+ " }\n" + >+ " },\n" + >+ " MINUS {\n" + >+ " @Override\n" + >+ " abstract double eval(double x, double y);\n" + >+ " };\n" + >+ "\n" + >+ " abstract double eval(double x, double y);\n" + >+ "}\n" + >+ "\n", // ================= >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " double eval(double x, double y) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "The method eval(double, double) of type new X(){} should be tagged with @Override since it actually overrides a superclass method\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " abstract double eval(double x, double y);\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "The abstract method eval in type new X(){} can only be defined by an abstract class\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=156591 - variation >+public void test139() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public enum X {\n" + >+ " PLUS {\n" + >+ " double eval(double x, double y) {\n" + >+ " return x + y;\n" + >+ " }\n" + >+ " },\n" + >+ " MINUS {\n" + >+ " abstract double eval2(double x, double y);\n" + >+ " };\n" + >+ "\n" + >+ " abstract double eval(double x, double y);\n" + >+ "}\n" + >+ "\n", // ================= >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " double eval(double x, double y) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "The method eval(double, double) of type new X(){} should be tagged with @Override since it actually overrides a superclass method\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " MINUS {\n" + >+ " ^\n" + >+ "The type new X(){} must implement the inherited abstract method X.eval(double, double)\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " abstract double eval2(double x, double y);\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "The abstract method eval2 in type new X(){} can only be defined by an abstract class\n" + >+ "----------\n"); >+} > } >\ No newline at end of file >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.139 >diff -u -r1.139 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 8 Sep 2006 01:09:04 -0000 1.139 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 8 Sep 2006 10:08:29 -0000 >@@ -456,14 +456,15 @@ > if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) > problemReporter().illegalModifierForEnum(sourceType); > } >- >- // what about inherited interface methods? >- if ((referenceContext.bits & ASTNode.HasAbstractMethods) != 0) { >- modifiers |= ClassFileConstants.AccAbstract; >- } else if (!sourceType.isAnonymousType()) { >- // body of enum constant must implement any inherited abstract methods >- // enum type needs to implement abstract methods if one of its constants does not supply a body >+ if (!sourceType.isAnonymousType()) { > checkAbstractEnum: { >+ // does define abstract methods ? >+ if ((referenceContext.bits & ASTNode.HasAbstractMethods) != 0) { >+ modifiers |= ClassFileConstants.AccAbstract; >+ break checkAbstractEnum; >+ } >+ // body of enum constant must implement any inherited abstract methods >+ // enum type needs to implement abstract methods if one of its constants does not supply a body > TypeDeclaration typeDeclaration = this.referenceContext; > FieldDeclaration[] fields = typeDeclaration.fields; > int fieldsLength = fields == null ? 0 : fields.length;
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 156591
:
49701
|
49705