Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.1-rc-1
-
Fix Version/s: 1.1-rc-2
-
Component/s: None
-
Labels:None
-
Environment:Windows 2000
Groovy Version: 1.1-rc-1
JVM: 1.6.0_02-b05
-
Number of attachments :
Description
The following code snippet can not be run, but after I used the full name such as Fruit.APPLE, Fruit.ORANGE, Fruit.BANANA, the code can be run successfully.
public enum Fruit { APPLE, ORANGE, BANANA } Fruit f = Fruit.BANANA println f switch (f) { case APPLE: println "Apple" break case ORANGE: println "Orange" break case BANANA: println "Banana" break default: println "Will not reach!" break }
Activity
Paul King
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
The following code snippet can not be run, but after I used the full name such as Fruit.APPLE, Fruit.ORANGE, Fruit.BANANA, the code can be run successfully. public enum Fruit { APPLE, ORANGE, BANANA } Fruit f = Fruit.BANANA println f switch (f) { case APPLE: println "Apple" break case ORANGE: println "Orange" break case BANANA: println "Banana" break default: println "Will not reach!" break } |
The following code snippet can not be run, but after I used the full name such as Fruit.APPLE, Fruit.ORANGE, Fruit.BANANA, the code can be run successfully. {code} public enum Fruit { APPLE, ORANGE, BANANA } Fruit f = Fruit.BANANA println f switch (f) { case APPLE: println "Apple" break case ORANGE: println "Orange" break case BANANA: println "Banana" break default: println "Will not reach!" break } {code} |
blackdrag blackdrag
made changes -
| Resolution | Won't Fix [ 2 ] | |
| Status | Open [ 1 ] | Closed [ 6 ] |
| Assignee | Jochen Theodorou [ blackdrag ] |
Indeed. Not only does Java allow the class name to be dropped, it requires it: