GROOVY-8369: Statically compiled property access on enum class throws 
NoSuchFieldError (tweak tests - closes #625)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/30905ec6
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/30905ec6
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/30905ec6

Branch: refs/heads/GROOVY_2_4_X
Commit: 30905ec659c35f8b07289cdc8ccec2f5b3671f8f
Parents: 82fbec4
Author: paulk <[email protected]>
Authored: Wed Nov 1 17:37:12 2017 +1000
Committer: paulk <[email protected]>
Committed: Wed Nov 1 19:14:59 2017 +1000

----------------------------------------------------------------------
 src/test/gls/enums/EnumTest.groovy                       | 11 +++++++++++
 .../asm/sc/FieldsAndPropertiesStaticCompileTest.groovy   |  3 +--
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/30905ec6/src/test/gls/enums/EnumTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/gls/enums/EnumTest.groovy 
b/src/test/gls/enums/EnumTest.groovy
index f858dfd..a0a4d8c 100644
--- a/src/test/gls/enums/EnumTest.groovy
+++ b/src/test/gls/enums/EnumTest.groovy
@@ -592,6 +592,17 @@ class EnumTest extends CompilableTestSupport {
             assert UsState.ID.toString() == 'Idaho'
         '''
     }
+
+    void testEnumConstantsTakePrecedenceOverClassProperties() {
+        assertScript '''
+            @Deprecated
+            enum Foo {
+                annotations
+            }
+            assert 'annotations' == Foo.annotations.toString()
+            assert Foo.getAnnotations().size() == 1
+          '''
+    }
 }
 
 enum UsCoin {

http://git-wip-us.apache.org/repos/asf/groovy/blob/30905ec6/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
----------------------------------------------------------------------
diff --git 
a/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
 
b/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
index 2bf0a86..eef6232 100644
--- 
a/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
+++ 
b/src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy
@@ -704,8 +704,7 @@ import 
org.codehaus.groovy.transform.sc.ListOfExpressionsExpression
                 enum Foo {}
 
                 def test() {
-                    println Foo.getModifiers() // => 16401 // ENUM | FINAL | 
PUBLIC (see GROOVY_8360 wrt STATIC)
-                    println Foo.modifiers      // java.lang.NoSuchFieldError: 
modifiers
+                    assert Foo.getModifiers() == Foo.modifiers
                 }    
                 test()
             '''

Reply via email to