groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: GROOVY-7402: Compiler NPE Related To AST Transformations And Traits (closes #499)
Date Wed, 01 Mar 2017 13:07:08 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 78a68845c -> 8a95665b6


GROOVY-7402: Compiler NPE Related To AST Transformations And Traits (closes #499)


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

Branch: refs/heads/master
Commit: 8a95665b640f6ea702b41a788fbae8222bf230fa
Parents: 78a6884
Author: paulk <paulk@asert.com.au>
Authored: Sat Feb 18 16:17:49 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Wed Mar 1 23:05:39 2017 +1000

----------------------------------------------------------------------
 .../groovy/transform/ImmutableASTTransformation.java     | 11 ++++++++---
 .../groovy/transform/trait/TraitASTTransformation.java   |  8 +++++---
 2 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8a95665b/src/main/org/codehaus/groovy/transform/ImmutableASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/ImmutableASTTransformation.java b/src/main/org/codehaus/groovy/transform/ImmutableASTTransformation.java
index 4378f0b..65bfa40 100644
--- a/src/main/org/codehaus/groovy/transform/ImmutableASTTransformation.java
+++ b/src/main/org/codehaus/groovy/transform/ImmutableASTTransformation.java
@@ -271,9 +271,14 @@ public class ImmutableASTTransformation extends AbstractASTTransformation
{
         return immutables;
     }
 
-    private static void makeClassFinal(ClassNode cNode) {
-        if ((cNode.getModifiers() & ACC_FINAL) == 0) {
-            cNode.setModifiers(cNode.getModifiers() | ACC_FINAL);
+    private void makeClassFinal(ClassNode cNode) {
+        int modifiers = cNode.getModifiers();
+        if ((modifiers & ACC_FINAL) == 0) {
+            if ((modifiers & (ACC_ABSTRACT | ACC_SYNTHETIC)) == (ACC_ABSTRACT | ACC_SYNTHETIC))
{
+                addError("Error during " + MY_TYPE_NAME + " processing: annotation found
on inappropriate class " + cNode.getName(), cNode);
+                return;
+            }
+            cNode.setModifiers(modifiers | ACC_FINAL);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/8a95665b/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java b/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
index f287284..5ff3bb7 100644
--- a/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
+++ b/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
@@ -576,9 +576,11 @@ public class TraitASTTransformation extends AbstractASTTransformation
implements
 
         @Override
         public Expression transform(final Expression exp) {
-            Expression replacement = exp.getNodeMetaData(TraitASTTransformation.POST_TYPECHECKING_REPLACEMENT);
-            if (replacement!=null) {
-                return replacement;
+            if (exp != null) {
+                Expression replacement = exp.getNodeMetaData(TraitASTTransformation.POST_TYPECHECKING_REPLACEMENT);
+                if (replacement!=null) {
+                    return replacement;
+                }
             }
             return super.transform(exp);
         }


Mime
View raw message