You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/12/09 07:08:32 UTC

[groovy] branch GROOVY_3_0_X updated (306f9e3 -> 4a2bc42)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 306f9e3  GROOVY-9330: Bump javaparser to 3.15.6
     new 03cefbc  minor edits
     new 007e77c  fix generics handling and other minor edits
     new d9eb08d  rework fixture
     new 4a2bc42  Don't transfer import source ranges to static properties or method calls

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/codehaus/groovy/ast/ClassHelper.java  |   2 +-
 .../java/org/codehaus/groovy/ast/GenericsType.java |   2 +-
 .../java/org/codehaus/groovy/ast/ModuleNode.java   |   2 +-
 .../org/codehaus/groovy/ast/VariableScope.java     |  56 +++--
 .../groovy/ast/expr/ClosureExpression.java         |   2 +-
 .../groovy/ast/expr/ConstantExpression.java        |   4 +-
 .../codehaus/groovy/ast/expr/EmptyExpression.java  |   4 +-
 .../codehaus/groovy/ast/stmt/EmptyStatement.java   |   9 +-
 .../codehaus/groovy/ast/tools/GenericsUtils.java   |   2 +
 .../groovy/classgen/AnnotationVisitor.java         |  18 +-
 .../classgen/asm/OptimizingStatementWriter.java    |  14 +-
 .../codehaus/groovy/control/ErrorCollector.java    | 269 ++++++++++-----------
 .../codehaus/groovy/control/ProcessingUnit.java    |   2 +-
 .../codehaus/groovy/control/ResolveVisitor.java    | 167 ++++++-------
 .../org/codehaus/groovy/control/SourceUnit.java    |   6 +-
 .../groovy/control/StaticImportVisitor.java        |   4 +-
 .../groovy/transform/ASTTransformationVisitor.java |  23 +-
 .../transform/AnnotationCollectorTransform.java    |   1 +
 .../groovy/transform/LogASTTransformation.java     |   1 -
 .../groovy/transform/NewifyASTTransformation.java  |  20 +-
 .../stc/AbstractExtensionMethodCache.java          |   2 +-
 .../transform/stc/StaticTypeCheckingSupport.java   |  46 ++--
 .../transform/trait/TraitASTTransformation.java    |   4 +-
 .../transform/trait/TraitReceiverTransformer.java  |   8 +-
 .../AnnotationClosureThisObjectCallTest.groovy     |   7 +-
 .../runtime/powerassert/AssertionTestUtil.groovy   |  13 +-
 .../src/spec/test/json/JsonBuilderTest.groovy      |  33 ++-
 27 files changed, 355 insertions(+), 366 deletions(-)


[groovy] 04/04: Don't transfer import source ranges to static properties or method calls

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4a2bc42995f444a15c1e142b48f7985feff23ae5
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Dec 7 14:19:25 2019 -0600

    Don't transfer import source ranges to static properties or method calls
    
    https://github.com/groovy/groovy-eclipse/issues/727
    
    import static Foo.getSomeThing as something
    @groovy.transform.CompileStatic
    class Bar {
      def baz(x, y) {
        something(x, y) // includes "Foo" (line 1, column 14)
      }
    }
    
    (cherry picked from commit e4dbbae65caa277fa0aca289e2863b9c9214be82)
---
 src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java b/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java
index e8557a7..1dea516 100644
--- a/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java
@@ -558,11 +558,11 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
     }
 
     private static PropertyExpression newStaticPropertyX(ClassNode type, String name) {
-        return new PropertyExpression(new ClassExpression(type), name);
+        return new PropertyExpression(new ClassExpression(type.getPlainNodeReference()), name);
     }
 
     private static StaticMethodCallExpression newStaticMethodCallX(ClassNode type, String name, Expression args) {
-        return new StaticMethodCallExpression(type, name, args);
+        return new StaticMethodCallExpression(type.getPlainNodeReference(), name, args);
     }
 
     protected SourceUnit getSourceUnit() {


[groovy] 02/04: fix generics handling and other minor edits

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 007e77c24562a75c1b8405cf12ba6f8858611c5e
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Dec 7 13:33:21 2019 -0600

    fix generics handling and other minor edits
    
    (cherry picked from commit 17185c94fe17148492dd5b0c1a1112a2427fd19d)
---
 .../codehaus/groovy/control/ErrorCollector.java    | 269 ++++++++++-----------
 1 file changed, 122 insertions(+), 147 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ErrorCollector.java b/src/main/java/org/codehaus/groovy/control/ErrorCollector.java
index 232d3df..60fb05e 100644
--- a/src/main/java/org/codehaus/groovy/control/ErrorCollector.java
+++ b/src/main/java/org/codehaus/groovy/control/ErrorCollector.java
@@ -39,75 +39,74 @@ import java.util.List;
 public class ErrorCollector implements Serializable {
 
     private static final long serialVersionUID = 2844774170905056755L;
+
     /**
-     * WarningMessages collected during processing
+     * ErrorMessages collected during processing
      */
-    protected LinkedList warnings;
+    protected LinkedList<Message> errors;
+
     /**
-     * ErrorMessages collected during processing
+     * WarningMessages collected during processing
      */
-    protected LinkedList errors;
+    protected LinkedList<WarningMessage> warnings;
+
     /**
      * Configuration and other settings that control processing
      */
-    protected CompilerConfiguration configuration;
+    protected final CompilerConfiguration configuration;
 
     /**
      * Initialize the ErrorReporter.
      */
-    public ErrorCollector(CompilerConfiguration configuration) {
-        this.warnings = null;
-        this.errors = null;
-        
+    public ErrorCollector(final CompilerConfiguration configuration) {
         this.configuration = configuration;
     }
-    
-    public void addCollectorContents(ErrorCollector er) {
-        if (er.errors!=null) {
-            if (errors==null) {
-                errors = er.errors;
+
+    public void addCollectorContents(final ErrorCollector that) {
+        if (that.errors != null) {
+            if (this.errors == null) {
+                this.errors = that.errors;
             } else {
-                errors.addAll(er.errors);
+                this.errors.addAll(that.errors);
             }
         }
-        if (er.warnings!=null) {
-            if (warnings==null) {
-                warnings = er.warnings;
+        if (that.warnings != null) {
+            if (this.warnings == null) {
+                this.warnings = that.warnings;
             } else {
-                warnings.addAll(er.warnings);
-            }            
+                this.warnings.addAll(that.warnings);
+            }
         }
     }
 
-    public void addErrorAndContinue(SyntaxException error, SourceUnit source) throws CompilationFailedException {
+    public void addErrorAndContinue(final SyntaxException error, final SourceUnit source) throws CompilationFailedException {
         addErrorAndContinue(Message.create(error, source));
     }
-    
+
     /**
      * Adds an error to the message set, but does not cause a failure. The message is not required to have a source
-     * line and column specified, but it is best practice to try and include that information. 
+     * line and column specified, but it is best practice to try and include that information.
      */
-    public void addErrorAndContinue(Message message) {
-        if (this.errors == null) {
-            this.errors = new LinkedList();
+    public void addErrorAndContinue(final Message message) {
+        if (errors == null) {
+            errors = new LinkedList<>();
         }
-
-        this.errors.add(message);
+        errors.add(message);
     }
-    
+
     /**
      * Adds a non-fatal error to the message set, which may cause a failure if the error threshold is exceeded.
      * The message is not required to have a source line and column specified, but it is best practice to try
      * and include that information.
      */
-    public void addError(Message message) throws CompilationFailedException {
+    public void addError(final Message message) throws CompilationFailedException {
         addErrorAndContinue(message);
 
-        if (errors!=null && this.errors.size() >= configuration.getTolerance()) {
+        if (errors != null && errors.size() >= configuration.getTolerance()) {
             failIfErrors();
         }
     }
-    
+
     /**
      * Adds an optionally-fatal error to the message set.
      * The message is not required to have a source line and column specified, but it is best practice to try
@@ -115,52 +114,63 @@ public class ErrorCollector implements Serializable {
      * @param fatal
      *      if true then then processing will stop
      */
-    public void addError(Message message, boolean fatal) throws CompilationFailedException {
+    public void addError(final Message message, final boolean fatal) throws CompilationFailedException {
         if (fatal) {
             addFatalError(message);
-        }
-        else {
+        } else {
             addError(message);
         }
     }
 
-    
-    /**
-     * Convenience wrapper for addError().
-     */
-    public void addError(SyntaxException error, SourceUnit source) throws CompilationFailedException {
+    public void addError(final SyntaxException error, final SourceUnit source) throws CompilationFailedException {
         addError(Message.create(error, source), error.isFatal());
     }
 
+    public void addError(final String error, final CSTNode context, final SourceUnit source) throws CompilationFailedException {
+        addError(new LocatedMessage(error, context, source));
+    }
 
-    /**
-     * Convenience wrapper for addError().
-     */
-    public void addError(String text, CSTNode context, SourceUnit source) throws CompilationFailedException {
-        addError(new LocatedMessage(text, context, source));
+    public void addException(final Exception exception, final SourceUnit source) throws CompilationFailedException {
+        addError(new ExceptionMessage(exception, configuration.getDebug(), source));
+        failIfErrors();
     }
-    
-    
+
     /**
-     * Adds a fatal exception to the message set and throws
-     * the unit as a PhaseFailedException.
+     * Adds an error to the message set and throws CompilationFailedException.
      */
-    public void addFatalError(Message message) throws CompilationFailedException {
+    public void addFatalError(final Message message) throws CompilationFailedException {
         addError(message);
         failIfErrors();
     }
 
+    /**
+     * Adds a warning to the message set.
+     */
+    public void addWarning(final WarningMessage message) {
+        if (message.isRelevant(configuration.getWarningLevel())) {
+            if (warnings == null) {
+                warnings = new LinkedList<>();
+            }
+            warnings.add(message);
+        }
+    }
 
-    public void addException(Exception cause, SourceUnit source) throws CompilationFailedException {
-        addError(new ExceptionMessage(cause,configuration.getDebug(),source));
-        failIfErrors();
+    /**
+     * Adds a warning to the message set if it is relevant.
+     */
+    public void addWarning(final int importance, final String text, final CSTNode context, final SourceUnit source) {
+        if (WarningMessage.isRelevant(importance, configuration.getWarningLevel())) {
+            addWarning(new WarningMessage(importance, text, context, source));
+        }
     }
 
     /**
-     * Returns true if there are any errors pending.
+     * Adds a warning to the message set if it is relevant.
      */
-    public boolean hasErrors() {
-        return this.errors != null;
+    public void addWarning(final int importance, final String text, final Object data, final CSTNode context, final SourceUnit source) {
+        if (WarningMessage.isRelevant(importance, configuration.getWarningLevel())) {
+            addWarning(new WarningMessage(importance, text, data, context, source));
+        }
     }
 
     /**
@@ -171,94 +181,86 @@ public class ErrorCollector implements Serializable {
     }
 
     /**
-     * Returns true if there are any warnings pending.
+     * Returns the number of errors.
      */
-    public boolean hasWarnings() {
-        return this.warnings != null;
+    public int getErrorCount() {
+        return (hasErrors() ? errors.size() : 0);
     }
-    
+
     /**
-     * Returns the list of warnings, or null if there are none.
+     * Returns the specified error message, or null.
      */
-    public List getWarnings() {
-        return this.warnings;
+    public Message getError(final int index) {
+        if (index < getErrorCount()) {
+            return errors.get(index);
+        }
+        return null;
     }
 
     /**
      * Returns the list of errors, or null if there are none.
      */
-    public List getErrors() {
-        return this.errors;
+    public List<? extends Message> getErrors() {
+        return errors;
     }
 
     /**
-     * Returns the number of warnings.
+     * Returns true if there are any errors pending.
      */
-    public int getWarningCount() {
-        return ((this.warnings == null) ? 0 : this.warnings.size());
+    public boolean hasErrors() {
+        return (errors != null);
     }
 
     /**
-     * Returns the number of errors.
+     * Returns the number of warnings.
      */
-    public int getErrorCount() {
-        return ((this.errors == null) ? 0 : this.errors.size());
+    public int getWarningCount() {
+        return (hasWarnings() ? warnings.size() : 0);
     }
 
     /**
      * Returns the specified warning message, or null.
      */
-    public WarningMessage getWarning(int index) {
+    public WarningMessage getWarning(final int index) {
         if (index < getWarningCount()) {
-            return (WarningMessage) this.warnings.get(index);
+            return warnings.get(index);
         }
         return null;
     }
 
     /**
-     * Returns the specified error message, or null.
+     * Returns the list of warnings, or null if there are none.
      */
-    public Message getError(int index) {
-        if (index < getErrorCount()) {
-            return (Message) this.errors.get(index);
-        }
-        return null;
+    public List<WarningMessage> getWarnings() {
+        return warnings;
     }
 
     /**
-     * Returns the last error reported
+     * Returns true if there are any warnings pending.
      */
-    public Message getLastError() {
-        return (Message) this.errors.getLast();
+    public boolean hasWarnings() {
+        return (warnings != null);
     }
-    
+
+    //
+
     /**
-     * Convenience routine to return the specified error's
-     * underlying SyntaxException, or null if it isn't one.
+     * Returns the last error reported.
      */
-    public SyntaxException getSyntaxError(int index) {
-        SyntaxException exception = null;
-
-        Message message = getError(index);
-        if (message instanceof SyntaxErrorMessage) {
-            exception = ((SyntaxErrorMessage) message).getCause();
-        }
-        return exception;
+    public Message getLastError() {
+        return errors.getLast();
     }
 
     /**
-     * Convenience routine to return the specified error's
-     * underlying Exception, or null if it isn't one.
+     * Returns the specified error's underlying Exception, or null if it isn't one.
      */
-    public Exception getException(int index) {
+    public Exception getException(final int index) {
         Exception exception = null;
-
         Message message = getError(index);
         if (message != null) {
             if (message instanceof ExceptionMessage) {
                 exception = ((ExceptionMessage) message).getCause();
-            }
-            else if (message instanceof SyntaxErrorMessage) {
+            } else if (message instanceof SyntaxErrorMessage) {
                 exception = ((SyntaxErrorMessage) message).getCause();
             }
         }
@@ -266,80 +268,53 @@ public class ErrorCollector implements Serializable {
     }
 
     /**
-     * Adds a WarningMessage to the message set.
-     */
-    public void addWarning(WarningMessage message) {
-        if (message.isRelevant(configuration.getWarningLevel())) {
-            if (this.warnings == null) {
-                this.warnings = new LinkedList();
-            }
-
-            this.warnings.add(message);
-        }
-    }
-
-
-    /**
-     * Convenience wrapper for addWarning() that won't create an object
-     * unless it is relevant.
-     */
-    public void addWarning(int importance, String text, CSTNode context, SourceUnit source) {
-        if (WarningMessage.isRelevant(importance, configuration.getWarningLevel())) {
-            addWarning(new WarningMessage(importance, text, context, source));
-        }
-    }
-    
-    
-    /**
-     * Convenience wrapper for addWarning() that won't create an object
-     * unless it is relevant.
+     * Returns the specified error's underlying SyntaxException, or null if it isn't one.
      */
-    public void addWarning(int importance, String text, Object data, CSTNode context, SourceUnit source) {
-        if (WarningMessage.isRelevant(importance, configuration.getWarningLevel())) {
-            addWarning(new WarningMessage(importance, text, data, context, source));
+    public SyntaxException getSyntaxError(final int index) {
+        SyntaxException exception = null;
+        Message message = getError(index);
+        if (message instanceof SyntaxErrorMessage) {
+            exception = ((SyntaxErrorMessage) message).getCause();
         }
+        return exception;
     }
-   
 
     /**
-     * Causes the current phase to fail by throwing a
-     * CompilationFailedException.
+     * Causes the current phase to fail by throwing a CompilationFailedException.
      */
     protected void failIfErrors() throws CompilationFailedException {
         if (hasErrors()) {
             throw new MultipleCompilationErrorsException(this);
         }
     }
-    
+
     //---------------------------------------------------------------------------
     // OUTPUT
 
+    private void write(final PrintWriter writer, final Janitor janitor, final List<? extends Message> messages, final String txt) {
+        if (messages == null || messages.isEmpty()) return;
 
-    private void write(PrintWriter writer, Janitor janitor, List messages, String txt) {
-        if (messages==null || messages.isEmpty()) return;
-        for (Object o : messages) {
-            Message message = (Message) o;
+        for (Message message : messages) {
             message.write(writer, janitor);
-
             if (configuration.getDebug() && (message instanceof SyntaxErrorMessage)) {
-                SyntaxErrorMessage sem = (SyntaxErrorMessage) message;
-                sem.getCause().printStackTrace(writer);
+                ((SyntaxErrorMessage) message).getCause().printStackTrace(writer);
             }
             writer.println();
         }
 
         writer.print(messages.size());
-        writer.print(" "+txt);
-        if (messages.size()>1) writer.print("s");
+        writer.print(" " + txt);
+        if (messages.size() > 1) {
+            writer.print("s");
+        }
         writer.println();
     }
-    
+
     /**
      * Writes error messages to the specified PrintWriter.
      */
-    public void write(PrintWriter writer, Janitor janitor) {
-        write(writer,janitor,warnings,"warning");
-        write(writer,janitor,errors,"error");
+    public void write(final PrintWriter writer, final Janitor janitor) {
+        write(writer, janitor, warnings, "warning");
+        write(writer, janitor, errors, "error");
     }
-
 }


[groovy] 01/04: minor edits

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 03cefbc9e9e180f690c464a59a17c708ef1e7dbd
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Dec 7 12:50:37 2019 -0600

    minor edits
    
    (cherry picked from commit 74a7c956bb795dcab8594428b8a9fb9c3d34487c)
---
 .../java/org/codehaus/groovy/ast/ClassHelper.java  |   2 +-
 .../java/org/codehaus/groovy/ast/GenericsType.java |   2 +-
 .../java/org/codehaus/groovy/ast/ModuleNode.java   |   2 +-
 .../org/codehaus/groovy/ast/VariableScope.java     |  56 ++++---
 .../groovy/ast/expr/ClosureExpression.java         |   2 +-
 .../groovy/ast/expr/ConstantExpression.java        |   4 +-
 .../codehaus/groovy/ast/expr/EmptyExpression.java  |   4 +-
 .../codehaus/groovy/ast/stmt/EmptyStatement.java   |   9 +-
 .../codehaus/groovy/ast/tools/GenericsUtils.java   |   2 +
 .../groovy/classgen/AnnotationVisitor.java         |  18 +--
 .../classgen/asm/OptimizingStatementWriter.java    |  14 +-
 .../codehaus/groovy/control/ProcessingUnit.java    |   2 +-
 .../codehaus/groovy/control/ResolveVisitor.java    | 167 +++++++++++----------
 .../org/codehaus/groovy/control/SourceUnit.java    |   6 +-
 .../groovy/transform/ASTTransformationVisitor.java |  23 ++-
 .../transform/AnnotationCollectorTransform.java    |   1 +
 .../groovy/transform/LogASTTransformation.java     |   1 -
 .../groovy/transform/NewifyASTTransformation.java  |  20 +--
 .../stc/AbstractExtensionMethodCache.java          |   2 +-
 .../transform/stc/StaticTypeCheckingSupport.java   |  46 +++---
 .../transform/trait/TraitASTTransformation.java    |   4 +-
 .../transform/trait/TraitReceiverTransformer.java  |   8 +-
 .../AnnotationClosureThisObjectCallTest.groovy     |   7 +-
 .../runtime/powerassert/AssertionTestUtil.groovy   |  13 +-
 24 files changed, 207 insertions(+), 208 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/ClassHelper.java b/src/main/java/org/codehaus/groovy/ast/ClassHelper.java
index bbca52a..9b30986 100644
--- a/src/main/java/org/codehaus/groovy/ast/ClassHelper.java
+++ b/src/main/java/org/codehaus/groovy/ast/ClassHelper.java
@@ -102,7 +102,6 @@ public class ClassHelper {
             DYNAMIC_TYPE = makeCached(Object.class),
             OBJECT_TYPE = DYNAMIC_TYPE,
             CLOSURE_TYPE = makeCached(Closure.class),
-            SERIALIZEDLAMBDA_TYPE = makeCached(SerializedLambda .class),
             GSTRING_TYPE = makeCached(GString.class),
             RANGE_TYPE = makeCached(Range.class),
             PATTERN_TYPE = makeCached(Pattern.class),
@@ -138,6 +137,7 @@ public class ClassHelper {
             ELEMENT_TYPE_TYPE = makeCached(ElementType.class),
             AUTOCLOSEABLE_TYPE = makeCached(AutoCloseable.class),
             SERIALIZABLE_TYPE = makeCached(Serializable.class),
+            SERIALIZEDLAMBDA_TYPE = makeCached(SerializedLambda.class),
 
             // uncached constants
             MAP_TYPE = makeWithoutCaching(Map.class),
diff --git a/src/main/java/org/codehaus/groovy/ast/GenericsType.java b/src/main/java/org/codehaus/groovy/ast/GenericsType.java
index 1e68788..59e3168 100644
--- a/src/main/java/org/codehaus/groovy/ast/GenericsType.java
+++ b/src/main/java/org/codehaus/groovy/ast/GenericsType.java
@@ -36,7 +36,7 @@ import static org.codehaus.groovy.ast.ClassHelper.GROOVY_OBJECT_TYPE;
  */
 public class GenericsType extends ASTNode {
     public static final GenericsType[] EMPTY_ARRAY = new GenericsType[0];
-    
+
     private final ClassNode[] upperBounds;
     private final ClassNode lowerBound;
     private ClassNode type;
diff --git a/src/main/java/org/codehaus/groovy/ast/ModuleNode.java b/src/main/java/org/codehaus/groovy/ast/ModuleNode.java
index 7033169..4e1376e 100644
--- a/src/main/java/org/codehaus/groovy/ast/ModuleNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ModuleNode.java
@@ -127,7 +127,7 @@ public class ModuleNode extends ASTNode implements Opcodes {
     }
 
     public void addImport(String alias, ClassNode type) {
-        addImport(alias, type, new ArrayList<>());
+        addImport(alias, type, Collections.emptyList());
     }
 
     public void addImport(String alias, ClassNode type, List<AnnotationNode> annotations) {
diff --git a/src/main/java/org/codehaus/groovy/ast/VariableScope.java b/src/main/java/org/codehaus/groovy/ast/VariableScope.java
index 9a32e8e..4b0fbfc 100644
--- a/src/main/java/org/codehaus/groovy/ast/VariableScope.java
+++ b/src/main/java/org/codehaus/groovy/ast/VariableScope.java
@@ -24,15 +24,14 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
- * Represents a variable scope. This is primarily used to determine variable sharing
- * across method and closure boundaries.
+ * Records declared and referenced variabes for a given scope.  Helps determine
+ * variable sharing across closure and method boundaries.
  */
-public class VariableScope  {
+public class VariableScope implements Cloneable {
 
     private VariableScope parent;
     private ClassNode classScope;
     private boolean inStaticContext;
-    private boolean resolvesDynamic;
 
     private Map<String, Variable> declaredVariables = Collections.emptyMap();
     private Map<String, Variable> referencedLocalVariables = Collections.emptyMap();
@@ -42,7 +41,7 @@ public class VariableScope  {
         super();
     }
 
-    public VariableScope(VariableScope parent) {
+    public VariableScope(final VariableScope parent) {
         this.parent = parent;
     }
 
@@ -51,7 +50,7 @@ public class VariableScope  {
     }
 
     public boolean isRoot() {
-        return parent == null;
+        return (parent == null);
     }
 
     /**
@@ -65,10 +64,10 @@ public class VariableScope  {
      * Returns true iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.
      */
     public boolean isClassScope() {
-        return classScope != null;
+        return (classScope != null);
     }
 
-    public void setClassScope(ClassNode classScope) {
+    public void setClassScope(final ClassNode classScope) {
         this.classScope = classScope;
     }
 
@@ -76,29 +75,29 @@ public class VariableScope  {
         return inStaticContext;
     }
 
-    public void setInStaticContext(boolean inStaticContext) {
+    public void setInStaticContext(final boolean inStaticContext) {
         this.inStaticContext = inStaticContext;
     }
 
     //
 
-    public Variable getDeclaredVariable(String name) {
+    public Variable getDeclaredVariable(final String name) {
         return declaredVariables.get(name);
     }
 
-    public Variable getReferencedLocalVariable(String name) {
+    public Variable getReferencedLocalVariable(final String name) {
         return referencedLocalVariables.get(name);
     }
 
-    public Variable getReferencedClassVariable(String name) {
+    public Variable getReferencedClassVariable(final String name) {
         return referencedClassVariables.get(name);
     }
 
-    public boolean isReferencedLocalVariable(String name) {
+    public boolean isReferencedLocalVariable(final String name) {
         return referencedLocalVariables.containsKey(name);
     }
 
-    public boolean isReferencedClassVariable(String name) {
+    public boolean isReferencedClassVariable(final String name) {
         return referencedClassVariables.containsKey(name);
     }
 
@@ -159,25 +158,25 @@ public class VariableScope  {
         return getReferencedClassVariables().values().iterator();
     }
 
-    public void putDeclaredVariable(Variable var) {
+    public void putDeclaredVariable(final Variable var) {
         if (declaredVariables == Collections.EMPTY_MAP)
             declaredVariables = new LinkedHashMap<>();
         declaredVariables.put(var.getName(), var);
     }
 
-    public void putReferencedLocalVariable(Variable var) {
+    public void putReferencedLocalVariable(final Variable var) {
         if (referencedLocalVariables == Collections.EMPTY_MAP)
             referencedLocalVariables = new LinkedHashMap<>();
         referencedLocalVariables.put(var.getName(), var);
     }
 
-    public void putReferencedClassVariable(Variable var) {
+    public void putReferencedClassVariable(final Variable var) {
         if (referencedClassVariables == Collections.EMPTY_MAP)
             referencedClassVariables = new LinkedHashMap<>();
         referencedClassVariables.put(var.getName(), var);
     }
 
-    public Object removeReferencedClassVariable(String name) {
+    public Object removeReferencedClassVariable(final String name) {
         if (referencedClassVariables.isEmpty()) {
             return null;
         } else {
@@ -189,19 +188,18 @@ public class VariableScope  {
 
     // TODO: implement Cloneable and override Object.clone()
     public VariableScope copy() {
-        VariableScope copy = new VariableScope(parent);
-        copy.classScope = classScope;
-        copy.inStaticContext = inStaticContext;
-        copy.resolvesDynamic = resolvesDynamic;
-        if (!declaredVariables.isEmpty()) {
-            copy.declaredVariables = new LinkedHashMap<>(declaredVariables);
+        VariableScope that = new VariableScope(parent);
+        that.classScope = this.classScope;
+        that.inStaticContext = this.inStaticContext;
+        if (!this.declaredVariables.isEmpty()) {
+            that.declaredVariables = new LinkedHashMap<>(this.declaredVariables);
         }
-        if (!referencedLocalVariables.isEmpty()) {
-            copy.referencedLocalVariables = new LinkedHashMap<>(referencedLocalVariables);
+        if (!this.referencedLocalVariables.isEmpty()) {
+            that.referencedLocalVariables = new LinkedHashMap<>(this.referencedLocalVariables);
         }
-        if (!referencedClassVariables.isEmpty()) {
-            copy.referencedClassVariables = new LinkedHashMap<>(referencedClassVariables);
+        if (!this.referencedClassVariables.isEmpty()) {
+            that.referencedClassVariables = new LinkedHashMap<>(this.referencedClassVariables);
         }
-        return copy;
+        return that;
     }
 }
diff --git a/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
index ccdceed..c8d1025 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
@@ -85,7 +85,7 @@ public class ClosureExpression extends Expression {
      * @return {@code true} if one or more explicit parameters are supplied
      */
     public boolean isParameterSpecified() {
-        return parameters != null && parameters.length > 0;
+        return (parameters != null && parameters.length > 0);
     }
 
     public VariableScope getVariableScope() {
diff --git a/src/main/java/org/codehaus/groovy/ast/expr/ConstantExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/ConstantExpression.java
index a9036a2..d958795 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/ConstantExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/ConstantExpression.java
@@ -22,7 +22,7 @@ import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.GroovyCodeVisitor;
 
 /**
- * Represents a constant expression such as null, true, false
+ * Represents a constant expression such as null, true, false.
  */
 public class ConstantExpression extends Expression {
     // The following fields are only used internally; every occurrence of a user-defined expression of the same kind
@@ -92,7 +92,7 @@ public class ConstantExpression extends Expression {
     }
 
     public String getText() {
-        return value == null ? "null" : value.toString();
+        return (value == null ? "null" : value.toString());
     }
 
     public String getConstantName() {
diff --git a/src/main/java/org/codehaus/groovy/ast/expr/EmptyExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/EmptyExpression.java
index ae7d6c3..c877f56 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/EmptyExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/EmptyExpression.java
@@ -37,7 +37,9 @@ public class EmptyExpression extends Expression {
     /**
      * @see EmptyExpression#INSTANCE
      */
-    public EmptyExpression() {}
+    public EmptyExpression() {
+        super();
+    }
 
     @Override
     public Expression transformExpression(ExpressionTransformer transformer) {
diff --git a/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java b/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java
index 1199e33..5365b88 100644
--- a/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java
+++ b/src/main/java/org/codehaus/groovy/ast/stmt/EmptyStatement.java
@@ -21,7 +21,6 @@ package org.codehaus.groovy.ast.stmt;
 import org.codehaus.groovy.ast.ASTNode;
 import org.codehaus.groovy.ast.GroovyCodeVisitor;
 
-import java.util.Collections;
 import java.util.Map;
 
 public class EmptyStatement extends Statement {
@@ -29,10 +28,8 @@ public class EmptyStatement extends Statement {
     /**
      * @see EmptyStatement#INSTANCE
      */
-    public EmptyStatement() {}
-
-    protected EmptyStatement(Map<?, ?> metaDataMap) {
-        super.setMetaDataMap(metaDataMap);
+    public EmptyStatement() {
+        super();
     }
 
     @Override
@@ -51,7 +48,7 @@ public class EmptyStatement extends Statement {
      * Immutable singleton that is recommended for use when source range or any
      * other occurrence-specific metadata is not needed.
      */
-    public static final EmptyStatement INSTANCE = new EmptyStatement(Collections.EMPTY_MAP) {
+    public static final EmptyStatement INSTANCE = new EmptyStatement() {
 
         private void throwUnsupportedOperationException() {
             throw new UnsupportedOperationException("EmptyStatement.INSTANCE is immutable");
diff --git a/src/main/java/org/codehaus/groovy/ast/tools/GenericsUtils.java b/src/main/java/org/codehaus/groovy/ast/tools/GenericsUtils.java
index 055e17f..cd3b166 100644
--- a/src/main/java/org/codehaus/groovy/ast/tools/GenericsUtils.java
+++ b/src/main/java/org/codehaus/groovy/ast/tools/GenericsUtils.java
@@ -482,8 +482,10 @@ public class GenericsUtils {
                         redirect = ClassHelper.OBJECT_TYPE;
                     }
                     if (redirect.isGenericsPlaceHolder()) {
+                        // "T extends U" or "T super U"
                         type = redirect;
                     } else {
+                        // "T" or "T extends Thing" or "T super Thing"
                         type = ClassHelper.makeWithoutCaching(name);
                         type.setGenericsPlaceHolder(true);
                         type.setRedirect(redirect);
diff --git a/src/main/java/org/codehaus/groovy/classgen/AnnotationVisitor.java b/src/main/java/org/codehaus/groovy/classgen/AnnotationVisitor.java
index 42eb463..3974262 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AnnotationVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AnnotationVisitor.java
@@ -85,7 +85,7 @@ public class AnnotationVisitor {
         if (!checkIfValidEnumConstsAreUsed(node)) {
             return node;
         }
-        
+
         Map<String, Expression> attributes = node.getMembers();
         for (Map.Entry<String, Expression> entry : attributes.entrySet()) {
             String attrName = entry.getKey();
@@ -97,7 +97,7 @@ public class AnnotationVisitor {
         VMPluginFactory.getPlugin().configureAnnotation(node);
         return this.annotation;
     }
-    
+
     private boolean checkIfValidEnumConstsAreUsed(AnnotationNode node) {
         Map<String, Expression> attributes = node.getMembers();
         for (Map.Entry<String, Expression> entry : attributes.entrySet()) {
@@ -106,7 +106,7 @@ public class AnnotationVisitor {
         }
         return true;
     }
-    
+
     private boolean validateEnumConstant(Expression exp) {
         if (exp instanceof PropertyExpression) {
             PropertyExpression pe = (PropertyExpression) exp;
@@ -154,7 +154,7 @@ public class AnnotationVisitor {
         // if it is an error, we have to test it at another place. But size==0 is
         // an error, because it means that no such attribute exists.
         if (methods.isEmpty()) {
-            addError("'" + attrName + "'is not part of the annotation " + classNode, node);
+            addError("'" + attrName + "'is not part of the annotation " + classNode.getNameWithoutPackage(), node);
             return ClassHelper.OBJECT_TYPE;
         }
         MethodNode method = (MethodNode) methods.get(0);
@@ -236,14 +236,11 @@ public class AnnotationVisitor {
         } else {
             addError(base, exp);
         }
-        return ConstantExpression.EMPTY_EXPRESSION;
+        ConstantExpression ret = new ConstantExpression(null);
+        ret.setSourcePosition(exp);
+        return ret;
     }
 
-    /**
-     * @param attrName   the name
-     * @param expression the expression
-     * @param attrType   the type
-     */
     protected void visitAnnotationExpression(String attrName, AnnotationConstantExpression expression, ClassNode attrType) {
         AnnotationNode annotationNode = (AnnotationNode) expression.getValue();
         AnnotationVisitor visitor = new AnnotationVisitor(this.source, this.errorCollector);
@@ -310,5 +307,4 @@ public class AnnotationVisitor {
             checkCircularReference(searchClass, method.getReturnType(), code.getExpression());
         }
     }
-
 }
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java
index 75fbf73..4377263 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java
@@ -755,8 +755,8 @@ public class OptimizingStatementWriter extends StatementWriter {
             if (resultType != null) {
                 addMeta(expression).type = resultType;
                 opt.chainInvolvedType(resultType);
-                opt.chainInvolvedType(leftType);
                 opt.chainInvolvedType(rightType);
+                opt.chainInvolvedType(leftType);
             }
         }
 
@@ -781,16 +781,15 @@ public class OptimizingStatementWriter extends StatementWriter {
 
         @Override
         public void visitDeclarationExpression(final DeclarationExpression expression) {
-            Expression right = expression.getRightExpression();
-            right.visit(this);
+            Expression rightExpression = expression.getRightExpression();
+            rightExpression.visit(this);
 
             ClassNode leftType = typeChooser.resolveType(expression.getLeftExpression(), node);
-            Expression rightExpression = expression.getRightExpression();
             ClassNode rightType = optimizeDivWithIntOrLongTarget(rightExpression, leftType);
-            if (rightType == null) rightType = typeChooser.resolveType(expression.getRightExpression(), node);
+            if (rightType == null) rightType = typeChooser.resolveType(rightExpression, node);
             if (isPrimitiveType(leftType) && isPrimitiveType(rightType)) {
                 // if right is a constant, then we optimize only if it makes a block complete, so we set a maybe
-                if (right instanceof ConstantExpression) {
+                if (rightExpression instanceof ConstantExpression) {
                     opt.chainCanOptimize(true);
                 } else {
                     opt.chainShouldOptimize(true);
@@ -868,8 +867,7 @@ public class OptimizingStatementWriter extends StatementWriter {
 
             ClassNode originalResultType = typeChooser.resolveType(binExp, node);
             if (!originalResultType.equals(BigDecimal_TYPE)
-                    || !(isLongCategory(assignmentTartgetType)
-                    || isFloatingCategory(assignmentTartgetType))) {
+                    || !(isLongCategory(assignmentTartgetType) || isFloatingCategory(assignmentTartgetType))) {
                 return null;
             }
 
diff --git a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
index af3f7c3..162fa6c 100644
--- a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
@@ -73,7 +73,7 @@ public abstract class ProcessingUnit {
     }
 
     /**
-     * Get the CompilerConfiguration for this ProcessingUnit.
+     * Gets the CompilerConfiguration for this ProcessingUnit.
      */
     public CompilerConfiguration getConfiguration() {
         return configuration;
diff --git a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
index 5230044..06e9df1 100644
--- a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
@@ -132,7 +132,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
     private static class ConstructedNestedClass extends ClassNode {
         final ClassNode knownEnclosingType;
 
-        public ConstructedNestedClass(ClassNode outer, String inner) {
+        public ConstructedNestedClass(final ClassNode outer, final String inner) {
             super(outer.getName() + "$" + inner.replace('.', '$'), Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
             this.knownEnclosingType = outer;
             this.isPrimaryNode = false;
@@ -151,7 +151,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
 
         @Override
-        public String setName(String name) {
+        public String setName(final String name) {
             if (redirect() != this) {
                 return super.setName(name);
             } else {
@@ -172,7 +172,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         final String prefix;
         String className;
 
-        public ConstructedClassWithPackage(String pkg, String name) {
+        public ConstructedClassWithPackage(final String pkg, final String name) {
             super(pkg + name, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
             isPrimaryNode = false;
             this.prefix = pkg;
@@ -194,7 +194,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
 
         @Override
-        public String setName(String name) {
+        public String setName(final String name) {
             if (redirect() != this) {
                 return super.setName(name);
             } else {
@@ -216,7 +216,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
     private static class LowerCaseClass extends ClassNode {
         final String className;
 
-        public LowerCaseClass(String name) {
+        public LowerCaseClass(final String name) {
             super(name, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
             isPrimaryNode = false;
             this.className = name;
@@ -237,7 +237,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
 
         @Override
-        public String setName(String name) {
+        public String setName(final String name) {
             if (redirect() != this) {
                 return super.setName(name);
             } else {
@@ -246,18 +246,27 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    public ResolveVisitor(CompilationUnit compilationUnit) {
+    public ResolveVisitor(final CompilationUnit compilationUnit) {
         this.compilationUnit = compilationUnit;
         setClassNodeResolver(new ClassNodeResolver());
     }
 
-    public void startResolving(ClassNode node, SourceUnit source) {
+    public void setClassNodeResolver(final ClassNodeResolver classNodeResolver) {
+        this.classNodeResolver = classNodeResolver;
+    }
+
+    public void startResolving(final ClassNode node, final SourceUnit source) {
         this.source = source;
         visitClass(node);
     }
 
     @Override
-    protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor) {
+    protected SourceUnit getSourceUnit() {
+        return source;
+    }
+
+    @Override
+    protected void visitConstructorOrMethod(final MethodNode node, final boolean isConstructor) {
         VariableScope oldScope = currentScope;
         currentScope = node.getVariableScope();
         Map<GenericsTypeName, GenericsType> oldPNames = genericParameterNames;
@@ -288,7 +297,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
     }
 
     @Override
-    public void visitField(FieldNode node) {
+    public void visitField(final FieldNode node) {
         ClassNode t = node.getType();
         if (!fieldTypesChecked.contains(node)) {
             resolveOrFail(t, node);
@@ -297,7 +306,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
     }
 
     @Override
-    public void visitProperty(PropertyNode node) {
+    public void visitProperty(final PropertyNode node) {
         Map<GenericsTypeName, GenericsType> oldPNames = genericParameterNames;
         if (node.isStatic() && !Traits.isTrait(node.getDeclaringClass())) {
             genericParameterNames = new HashMap<>();
@@ -311,7 +320,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         genericParameterNames = oldPNames;
     }
 
-    private boolean resolveToInner(ClassNode type) {
+    private boolean resolveToInner(final ClassNode type) {
         // we do not do our name mangling to find an inner class
         // if the type is a ConstructedClassWithPackage, because in this case we
         // are resolving the name at a different place already
@@ -331,7 +340,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private void resolveOrFail(ClassNode type, String msg, ASTNode node) {
+    private void resolveOrFail(final ClassNode type, final String msg, final ASTNode node) {
         if (resolve(type)) return;
         if (resolveToInner(type)) return;
         if (resolveToOuterNested(type)) return;
@@ -343,7 +352,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
     // if the type to resolve is an inner class and it is in an outer class which is not resolved,
     // we set the resolved type to a placeholder class node, i.e. a ConstructedOuterNestedClass instance
     // when resolving the outer class later, we set the resolved type of ConstructedOuterNestedClass instance to the actual inner class node(SEE GROOVY-7812(#2))
-    private boolean resolveToOuterNested(ClassNode type) {
+    private boolean resolveToOuterNested(final ClassNode type) {
         CompileUnit compileUnit = currentClass.getCompileUnit();
         String typeName = type.getName();
 
@@ -398,7 +407,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return toResolveFurther;
     }
 
-    private ConstructedOuterNestedClassNode tryToConstructOuterNestedClassNodeViaStaticImport(CompileUnit compileUnit, ImportNode importNode, String typeName, BiConsumer<ConstructedOuterNestedClassNode, ClassNode> setRedirectListener) {
+    private ConstructedOuterNestedClassNode tryToConstructOuterNestedClassNodeViaStaticImport(final CompileUnit compileUnit, final ImportNode importNode, final String typeName, final BiConsumer<ConstructedOuterNestedClassNode, ClassNode> setRedirectListener) {
         String importClassName = importNode.getClassName();
         ClassNode outerClassNode = compileUnit.getClass(importClassName);
 
@@ -410,7 +419,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return constructedOuterNestedClassNode;
     }
 
-    private ConstructedOuterNestedClassNode tryToConstructOuterNestedClassNode(ClassNode type, ClassNode outerClassNode, BiConsumer<ConstructedOuterNestedClassNode, ClassNode> setRedirectListener) {
+    private ConstructedOuterNestedClassNode tryToConstructOuterNestedClassNode(final ClassNode type, final ClassNode outerClassNode, final BiConsumer<ConstructedOuterNestedClassNode, ClassNode> setRedirectListener) {
         String outerClassName = outerClassNode.getName();
 
         for (String typeName = type.getName(), ident = typeName; ident.indexOf('.') != -1; ) {
@@ -426,7 +435,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return null;
     }
 
-    private ConstructedOuterNestedClassNode tryToConstructOuterNestedClassNodeForBaseType(CompileUnit compileUnit, String typeName, ClassNode cn, BiConsumer<ConstructedOuterNestedClassNode, ClassNode> setRedirectListener) {
+    private ConstructedOuterNestedClassNode tryToConstructOuterNestedClassNodeForBaseType(final CompileUnit compileUnit, final String typeName, final ClassNode cn, final BiConsumer<ConstructedOuterNestedClassNode, ClassNode> setRedirectListener) {
         if (!compileUnit.getClassesToCompile().containsValue(cn)) return null;
 
         String outerNestedClassName = cn.getName() + "$" + typeName;
@@ -435,21 +444,21 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return constructedOuterNestedClassNode;
     }
 
-    private void resolveOrFail(ClassNode type, ASTNode node, boolean prefereImports) {
+    private void resolveOrFail(final ClassNode type, final ASTNode node, final boolean prefereImports) {
         resolveGenericsTypes(type.getGenericsTypes());
         if (prefereImports && resolveAliasFromModule(type)) return;
         resolveOrFail(type, node);
     }
 
-    private void resolveOrFail(ClassNode type, ASTNode node) {
+    private void resolveOrFail(final ClassNode type, final ASTNode node) {
         resolveOrFail(type, "", node);
     }
 
-    private boolean resolve(ClassNode type) {
+    protected boolean resolve(final ClassNode type) {
         return resolve(type, true, true, true);
     }
 
-    private boolean resolve(ClassNode type, boolean testModuleImports, boolean testDefaultImports, boolean testStaticInnerClasses) {
+    protected boolean resolve(final ClassNode type, final boolean testModuleImports, final boolean testDefaultImports, final boolean testStaticInnerClasses) {
         resolveGenericsTypes(type.getGenericsTypes());
         if (type.isResolved() || type.isPrimaryClassNode()) return true;
         if (type.isArray()) {
@@ -488,7 +497,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
                 (testStaticInnerClasses && type.hasPackageName() && resolveFromStaticInnerClasses(type));
     }
 
-    private boolean resolveNestedClass(ClassNode type) {
+    protected boolean resolveNestedClass(final ClassNode type) {
         if (type instanceof ConstructedNestedClass || type instanceof ConstructedClassWithPackage) return false;
 
         // We have for example a class name A, are in class X
@@ -530,7 +539,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private boolean setRedirect(ClassNode type, ClassNode classToCheck) {
+    private boolean setRedirect(final ClassNode type, final ClassNode classToCheck) {
         String typeName = type.getName();
 
         Predicate<ClassNode> resolver = (ClassNode maybeOuter) -> {
@@ -559,13 +568,13 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private static String replaceLastPointWithDollar(String name) {
+    private static String replaceLastPointWithDollar(final String name) {
         int lastPointIndex = name.lastIndexOf('.');
 
         return name.substring(0, lastPointIndex) + "$" + name.substring(lastPointIndex + 1);
     }
 
-    private boolean resolveFromStaticInnerClasses(ClassNode type) {
+    protected boolean resolveFromStaticInnerClasses(final ClassNode type) {
         // a class consisting of a vanilla name can never be
         // a static inner class, because at least one dot is
         // required for this. Example: foo.bar -> foo$bar
@@ -593,7 +602,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private boolean resolveFromDefaultImports(ClassNode type) {
+    protected boolean resolveFromDefaultImports(final ClassNode type) {
         // we do not resolve a vanilla name starting with a lower case letter
         // try to resolve against a default import, because we know that the
         // default packages do not contain classes like these
@@ -626,7 +635,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
 
     private static final EvictableCache<String, Set<String>> DEFAULT_IMPORT_CLASS_AND_PACKAGES_CACHE = new UnlimitedConcurrentCache<>();
 
-    private boolean resolveFromDefaultImports(ClassNode type, String[] packagePrefixes) {
+    protected boolean resolveFromDefaultImports(final ClassNode type, final String[] packagePrefixes) {
         String typeName = type.getName();
 
         for (String packagePrefix : packagePrefixes) {
@@ -652,7 +661,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private boolean resolveFromCompileUnit(ClassNode type) {
+    protected boolean resolveFromCompileUnit(final ClassNode type) {
         // look into the compile unit if there is a class with that name
         CompileUnit compileUnit = currentClass.getCompileUnit();
         if (compileUnit == null) return false;
@@ -664,7 +673,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private void ambiguousClass(ClassNode type, ClassNode iType, String name) {
+    private void ambiguousClass(final ClassNode type, final ClassNode iType, final String name) {
         if (type.getName().equals(iType.getName())) {
             addError("reference to " + name + " is ambiguous, both class " + type.getName() + " and " + iType.getName() + " match", type);
         } else {
@@ -672,7 +681,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    private boolean resolveAliasFromModule(ClassNode type) {
+    private boolean resolveAliasFromModule(final ClassNode type) {
         // In case of getting a ConstructedClassWithPackage here we do not do checks for partial
         // matches with imported classes. The ConstructedClassWithPackage is already a constructed
         // node and any subclass resolving will then take place elsewhere
@@ -743,7 +752,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private boolean resolveFromModule(ClassNode type, boolean testModuleImports) {
+    protected boolean resolveFromModule(final ClassNode type, final boolean testModuleImports) {
         if (type instanceof ConstructedNestedClass) return false;
 
         // we decided if we have a vanilla name starting with a lower case
@@ -840,7 +849,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    private boolean resolveToOuter(ClassNode type) {
+    protected boolean resolveToOuter(final ClassNode type) {
         String name = type.getName();
 
         // We do not need to check instances of LowerCaseClass
@@ -869,7 +878,8 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return false;
     }
 
-    public Expression transform(Expression exp) {
+    @Override
+    public Expression transform(final Expression exp) {
         if (exp == null) return null;
         Expression ret;
         if (exp instanceof VariableExpression) {
@@ -898,7 +908,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return ret;
     }
 
-    private static String lookupClassName(PropertyExpression pe) {
+    private static String lookupClassName(final PropertyExpression pe) {
         boolean doInitialClassTest = true;
         StringBuilder name = new StringBuilder(32);
         // this loop builds a name from right to left each name part
@@ -939,7 +949,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return name.toString();
     }
 
-    private static Tuple2<StringBuilder, Boolean> makeClassName(boolean doInitialClassTest, StringBuilder name, String varName) {
+    private static Tuple2<StringBuilder, Boolean> makeClassName(final boolean doInitialClassTest, final StringBuilder name, final String varName) {
         if (doInitialClassTest) {
             // we are at the first name part. This is the right most part.
             // If this part is in lower case, then we do not need a class
@@ -948,23 +958,20 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
             // can still be resolved to the class foo.Bar and the static
             // field bar.
             if (!testVanillaNameForClass(varName)) {
-                name = null;
+                return tuple(null, Boolean.TRUE);
             } else {
-                doInitialClassTest = false;
-                name = new StringBuilder(varName);
+                return tuple(new StringBuilder(varName), Boolean.FALSE);
             }
-        } else {
-            name.insert(0, varName + ".");
         }
-
-        return tuple(name, doInitialClassTest);
+        name.insert(0, varName + ".");
+        return tuple(name, Boolean.FALSE);
     }
 
     // iterate from the inner most to the outer and check for classes
     // this check will ignore a .class property, for Example Integer.class will be
     // a PropertyExpression with the ClassExpression of Integer as objectExpression
     // and class as property
-    private static Expression correctClassClassChain(PropertyExpression pe) {
+    private static Expression correctClassClassChain(final PropertyExpression pe) {
         LinkedList<Expression> stack = new LinkedList<Expression>();
         ClassExpression found = null;
         for (Expression it = pe; it != null; it = ((PropertyExpression) it).getObjectExpression()) {
@@ -1019,8 +1026,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         if (className != null) {
             ClassNode type = ClassHelper.make(className);
             if (resolve(type)) {
-                Expression ret = new ClassExpression(type);
-                return ret;
+                return new ClassExpression(type);
             }
         }
         if (objectExpression instanceof ClassExpression && pe.getPropertyAsString() != null) {
@@ -1043,13 +1049,13 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return ret;
     }
 
-    private static boolean isVisibleNestedClass(ClassNode innerType, ClassNode outerType) {
+    private static boolean isVisibleNestedClass(final ClassNode innerType, final ClassNode outerType) {
         int modifiers = innerType.getModifiers();
         return Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)
                 || (!Modifier.isPrivate(modifiers) && Objects.equals(innerType.getPackageName(), outerType.getPackageName()));
     }
 
-    private boolean directlyImplementsTrait(ClassNode trait) {
+    private boolean directlyImplementsTrait(final ClassNode trait) {
         ClassNode[] interfaces = currentClass.getInterfaces();
         if (interfaces == null) {
             return currentClass.getSuperClass().equals(trait);
@@ -1062,7 +1068,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return currentClass.getSuperClass().equals(trait);
     }
 
-    private void checkThisAndSuperAsPropertyAccess(PropertyExpression expression) {
+    private void checkThisAndSuperAsPropertyAccess(final PropertyExpression expression) {
         if (expression.isImplicitThis()) return;
         String prop = expression.getPropertyAsString();
         if (prop == null) return;
@@ -1093,7 +1099,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    protected Expression transformVariableExpression(VariableExpression ve) {
+    protected Expression transformVariableExpression(final VariableExpression ve) {
         visitAnnotations(ve);
         Variable v = ve.getAccessedVariable();
 
@@ -1138,12 +1144,12 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return ve;
     }
 
-    private static boolean testVanillaNameForClass(String name) {
+    private static boolean testVanillaNameForClass(final String name) {
         if (name == null || name.length() == 0) return false;
         return !Character.isLowerCase(name.charAt(0));
     }
 
-    protected Expression transformBinaryExpression(BinaryExpression be) {
+    protected Expression transformBinaryExpression(final BinaryExpression be) {
         Expression left = transform(be.getLeftExpression());
         if (be.getOperation().isA(Types.ASSIGNMENT_OPERATOR) && left instanceof ClassExpression) {
             ClassExpression ce = (ClassExpression) left;
@@ -1204,7 +1210,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return be;
     }
 
-    protected Expression transformClosureExpression(ClosureExpression ce) {
+    protected Expression transformClosureExpression(final ClosureExpression ce) {
         boolean oldInClosure = inClosure;
         inClosure = true;
         for (Parameter para : getParametersSafe(ce)) {
@@ -1223,7 +1229,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return ce;
     }
 
-    protected Expression transformConstructorCallExpression(ConstructorCallExpression cce) {
+    protected Expression transformConstructorCallExpression(final ConstructorCallExpression cce) {
         findPossibleOuterClassNodeForNonStaticInnerClassInstantiation(cce);
 
         ClassNode type = cce.getType();
@@ -1235,7 +1241,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return cce.transformExpression(this);
     }
 
-    private void findPossibleOuterClassNodeForNonStaticInnerClassInstantiation(ConstructorCallExpression cce) {
+    private void findPossibleOuterClassNodeForNonStaticInnerClassInstantiation(final ConstructorCallExpression cce) {
         // GROOVY-8947: Fail to resolve non-static inner class outside of outer class
         // `new Computer().new Cpu(4)` will be parsed to `new Cpu(new Computer(), 4)`
         // so non-static inner class instantiation expression's first argument is a constructor call of outer class
@@ -1257,11 +1263,11 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    private static String getDescription(ClassNode node) {
+    private static String getDescription(final ClassNode node) {
         return (node.isInterface() ? "interface" : "class") + " '" + node.getName() + "'";
     }
 
-    protected Expression transformMethodCallExpression(MethodCallExpression mce) {
+    protected Expression transformMethodCallExpression(final MethodCallExpression mce) {
         Expression args = transform(mce.getArguments());
         Expression method = transform(mce.getMethod());
         Expression object = transform(mce.getObjectExpression());
@@ -1277,7 +1283,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return ret;
     }
 
-    protected Expression transformDeclarationExpression(DeclarationExpression de) {
+    protected Expression transformDeclarationExpression(final DeclarationExpression de) {
         visitAnnotations(de);
         Expression oldLeft = de.getLeftExpression();
         checkingVariableTypeInDeclaration = true;
@@ -1301,14 +1307,14 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return newDeclExpr;
     }
 
-    // TODO get normal resolving to set declaring class
-    private void fixDeclaringClass(DeclarationExpression newDeclExpr) {
+    // TODO: get normal resolving to set declaring class
+    private void fixDeclaringClass(final DeclarationExpression newDeclExpr) {
         if (newDeclExpr.getDeclaringClass() == null && currentMethod != null) {
             newDeclExpr.setDeclaringClass(currentMethod.getDeclaringClass());
         }
     }
 
-    protected Expression transformAnnotationConstantExpression(AnnotationConstantExpression ace) {
+    protected Expression transformAnnotationConstantExpression(final AnnotationConstantExpression ace) {
         AnnotationNode an = (AnnotationNode) ace.getValue();
         ClassNode type = an.getClassNode();
         resolveOrFail(type, " for annotation", an);
@@ -1318,7 +1324,8 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return ace;
     }
 
-    public void visitAnnotations(AnnotatedNode node) {
+    @Override
+    public void visitAnnotations(final AnnotatedNode node) {
         List<AnnotationNode> annotations = node.getAnnotations();
         if (annotations.isEmpty()) return;
         Map<String, AnnotationNode> tmpAnnotations = new HashMap<>();
@@ -1347,7 +1354,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    private boolean isRepeatable(Class<?> annTypeClass) {
+    private boolean isRepeatable(final Class<?> annTypeClass) {
         Annotation[] annTypeAnnotations = annTypeClass.getAnnotations();
         for (Annotation annTypeAnnotation : annTypeAnnotations) {
             if (annTypeAnnotation.annotationType().getName().equals("java.lang.annotation.Repeatable")) {
@@ -1375,7 +1382,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return exp;
     }
 
-    private void checkAnnotationMemberValue(Expression newValue) {
+    private void checkAnnotationMemberValue(final Expression newValue) {
         if (newValue instanceof PropertyExpression) {
             PropertyExpression pe = (PropertyExpression) newValue;
             if (!(pe.getObjectExpression() instanceof ClassExpression)) {
@@ -1389,7 +1396,8 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    public void visitClass(ClassNode node) {
+    @Override
+    public void visitClass(final ClassNode node) {
         ClassNode oldNode = currentClass;
 
         currentClass = node;
@@ -1468,7 +1476,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
     }
 
     // GROOVY-7812(#2): Static inner classes cannot be accessed from other files when running by 'groovy' command
-    private void resolveOuterNestedClassFurther(ClassNode node) {
+    private void resolveOuterNestedClassFurther(final ClassNode node) {
         CompileUnit compileUnit = currentClass.getCompileUnit();
 
         if (null == compileUnit) return;
@@ -1498,7 +1506,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    private void checkCyclicInheritance(ClassNode originalNode, ClassNode parentToCompare, ClassNode[] interfacesToCompare) {
+    private void checkCyclicInheritance(final ClassNode originalNode, final ClassNode parentToCompare, final ClassNode[] interfacesToCompare) {
         if (!originalNode.isInterface()) {
             if (parentToCompare == null) return;
             if (originalNode == parentToCompare.redirect()) {
@@ -1532,7 +1540,8 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    public void visitCatchStatement(CatchStatement cs) {
+    @Override
+    public void visitCatchStatement(final CatchStatement cs) {
         resolveOrFail(cs.getExceptionType(), cs);
         if (cs.getExceptionType() == ClassHelper.DYNAMIC_TYPE) {
             cs.getVariable().setType(ClassHelper.make(Exception.class));
@@ -1540,23 +1549,21 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         super.visitCatchStatement(cs);
     }
 
-    public void visitForLoop(ForStatement forLoop) {
+    @Override
+    public void visitForLoop(final ForStatement forLoop) {
         resolveOrFail(forLoop.getVariableType(), forLoop);
         super.visitForLoop(forLoop);
     }
 
-    public void visitBlockStatement(BlockStatement block) {
+    @Override
+    public void visitBlockStatement(final BlockStatement block) {
         VariableScope oldScope = currentScope;
         currentScope = block.getVariableScope();
         super.visitBlockStatement(block);
         currentScope = oldScope;
     }
 
-    protected SourceUnit getSourceUnit() {
-        return source;
-    }
-
-    private boolean resolveGenericsTypes(GenericsType[] types) {
+    private boolean resolveGenericsTypes(final GenericsType[] types) {
         if (types == null) return true;
         currentClass.setUsingGenerics(true);
         boolean resolved = true;
@@ -1567,11 +1574,11 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         return resolved;
     }
 
-    private void resolveGenericsHeader(GenericsType[] types) {
+    private void resolveGenericsHeader(final GenericsType[] types) {
         resolveGenericsHeader(types, null, 0);
     }
 
-    private void resolveGenericsHeader(GenericsType[] types, GenericsType rootType, int level) {
+    private void resolveGenericsHeader(final GenericsType[] types, final GenericsType rootType, final int level) {
         if (types == null) return;
         currentClass.setUsingGenerics(true);
         List<Tuple2<ClassNode, GenericsType>> upperBoundsWithGenerics = new LinkedList<>();
@@ -1638,7 +1645,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         }
     }
 
-    private boolean resolveGenericsType(GenericsType genericsType) {
+    private boolean resolveGenericsType(final GenericsType genericsType) {
         if (genericsType.isResolved()) return true;
         currentClass.setUsingGenerics(true);
         ClassNode type = genericsType.getType();
@@ -1674,11 +1681,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
 
     }
 
-    public void setClassNodeResolver(ClassNodeResolver classNodeResolver) {
-        this.classNodeResolver = classNodeResolver;
-    }
-
-    private static Map<String, ClassNode> findHierClasses(ClassNode currentClass) {
+    private static Map<String, ClassNode> findHierClasses(final ClassNode currentClass) {
         Map<String, ClassNode> hierClasses = new LinkedHashMap<>();
         for (ClassNode classToCheck = currentClass; classToCheck != ClassHelper.OBJECT_TYPE; classToCheck = classToCheck.getSuperClass()) {
             if (classToCheck == null || hierClasses.containsKey(classToCheck.getName())) break;
diff --git a/src/main/java/org/codehaus/groovy/control/SourceUnit.java b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
index f9b320c..7091222 100644
--- a/src/main/java/org/codehaus/groovy/control/SourceUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
@@ -254,14 +254,10 @@ public class SourceUnit extends ProcessingUnit {
         String property = (String) AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty("groovy.ast"));
 
         if ("xml".equals(property)) {
-            saveAsXML(name, ast);
+            XStreamUtils.serialize(name, ast);
         }
     }
 
-    private static void saveAsXML(String name, ModuleNode ast) {
-        XStreamUtils.serialize(name, ast);
-    }
-
     //---------------------------------------------------------------------------
     // SOURCE SAMPLING
 
diff --git a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
index d1afa34..c2c508f 100644
--- a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
@@ -119,8 +119,6 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
                 }
             }
 
-
-
             // invert the map, is now one to many
             transforms = new HashMap<ASTNode, List<ASTTransformation>>();
             for (Map.Entry<Class<? extends ASTTransformation>, Set<ASTNode>> entry : baseTransforms.entrySet()) {
@@ -204,7 +202,7 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
 
         compilationUnit.addPhaseOperation(new CompilationUnit.PrimaryClassNodeOperation() {
             public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException {
-                ASTTransformationCollectorCodeVisitor collector = 
+                ASTTransformationCollectorCodeVisitor collector =
                     new ASTTransformationCollectorCodeVisitor(source, compilationUnit.getTransformLoader());
                 collector.visitClass(classNode);
             }
@@ -230,11 +228,11 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
             }
         }
     }
-    
+
     public static void addGlobalTransformsAfterGrab(ASTTransformationsContext context) {
         doAddGlobalTransforms(context, false);
     }
-    
+
     public static void addGlobalTransforms(ASTTransformationsContext context) {
         doAddGlobalTransforms(context, true);
     }
@@ -293,7 +291,6 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
                             compilationUnit.getErrorCollector().addError(new SimpleMessage(
                                     "IOException reading the service definition at "
                                             + service.toExternalForm() + " because of exception " + ioe.toString(), null));
-                            //noinspection UnnecessaryContinue
                             continue;
                         }
                     }
@@ -306,9 +303,9 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
                 null));
         }
 
-        // record the transforms found in the first scan, so that in the 2nd scan, phase operations 
-        // can be added for only for new transforms that have come in 
-        if(isFirstScan) {
+        // record the transforms found in the first scan, so that in the 2nd scan, phase operations
+        // can be added for only for new transforms that have come in
+        if (isFirstScan) {
             for (Map.Entry<String, URL> entry : transformNames.entrySet()) {
                 context.getGlobalTransformNames().add(entry.getKey());
             }
@@ -319,14 +316,13 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
             addPhaseOperationsForGlobalTransforms(context.getCompilationUnit(), transformNames, isFirstScan);
         }
     }
-    
+
     private static void addPhaseOperationsForGlobalTransforms(CompilationUnit compilationUnit,
             Map<String, URL> transformNames, boolean isFirstScan) {
         GroovyClassLoader transformLoader = compilationUnit.getTransformLoader();
         for (Map.Entry<String, URL> entry : transformNames.entrySet()) {
             try {
                 Class gTransClass = transformLoader.loadClass(entry.getKey(), false, true, false);
-                //no inspection unchecked
                 GroovyASTTransformation transformAnnotation = (GroovyASTTransformation) gTransClass.getAnnotation(GroovyASTTransformation.class);
                 if (transformAnnotation == null) {
                     compilationUnit.getErrorCollector().addWarning(new WarningMessage(
@@ -347,8 +343,8 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
                         public void call(SourceUnit source) throws CompilationFailedException {
                             instance.visit(new ASTNode[] {source.getAST()}, source);
                         }
-                    }; 
-                    if(isFirstScan) {
+                    };
+                    if (isFirstScan) {
                         compilationUnit.addPhaseOperation(suOp, transformAnnotation.phase().getPhaseNumber());
                     } else {
                         compilationUnit.addNewPhaseOperation(suOp, transformAnnotation.phase().getPhaseNumber());
@@ -366,4 +362,3 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
         }
     }
 }
-
diff --git a/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java b/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
index f41feac..bf94211 100644
--- a/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
+++ b/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
@@ -62,6 +62,7 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC;
 
 /**
  * This class is the base for any annotation alias processor.
+ *
  * @see AnnotationCollector
  * @see AnnotationCollectorTransform#visit(AnnotationNode, AnnotationNode, AnnotatedNode, SourceUnit)
  */
diff --git a/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java
index e0e3b20..16a85f8 100644
--- a/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java
@@ -260,7 +260,6 @@ public class LogASTTransformation extends AbstractASTTransformation implements C
         } catch (Exception e) {
             return null;
         }
-
     }
 
 
diff --git a/src/main/java/org/codehaus/groovy/transform/NewifyASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/NewifyASTTransformation.java
index ae71b14..4cc060f 100644
--- a/src/main/java/org/codehaus/groovy/transform/NewifyASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/NewifyASTTransformation.java
@@ -345,7 +345,8 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
 
     private void checkDuplicateNameClashes(ListExpression list) {
         final Set<String> seen = new HashSet<String>();
-        @SuppressWarnings("unchecked") final List<ClassExpression> classes = (List) list.getExpressions();
+        @SuppressWarnings("unchecked")
+        List<ClassExpression> classes = (List) list.getExpressions();
         for (ClassExpression ce : classes) {
             final String name = ce.getType().getNameWithoutPackage();
             if (seen.contains(name)) {
@@ -363,7 +364,8 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
     }
 
     private void checkClassLevelClashes(ListExpression list) {
-        @SuppressWarnings("unchecked") final List<ClassExpression> classes = (List) list.getExpressions();
+        @SuppressWarnings("unchecked")
+        List<ClassExpression> classes = (List) list.getExpressions();
         for (ClassExpression ce : classes) {
             final String name = ce.getType().getNameWithoutPackage();
             if (findClassWithMatchingBasename(name)) {
@@ -373,10 +375,10 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
         }
     }
 
-
     private boolean isNewifyCandidate(MethodCallExpression mce) {
-        return mce.getObjectExpression() == VariableExpression.THIS_EXPRESSION
-                || (auto && isNewMethodStyle(mce));
+        return (auto && isNewMethodStyle(mce)) || (mce.isImplicitThis()
+                && mce.getObjectExpression() instanceof VariableExpression
+                && ((VariableExpression) mce.getObjectExpression()).isThisExpression());
     }
 
     private static boolean isNewMethodStyle(MethodCallExpression mce) {
@@ -428,7 +430,8 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
         }
 
         if (classesToNewify != null) {
-            @SuppressWarnings("unchecked") final List<ClassExpression> classes = (List) classesToNewify.getExpressions();
+            @SuppressWarnings("unchecked")
+            List<ClassExpression> classes = (List) classesToNewify.getExpressions();
             for (ClassExpression ce : classes) {
                 if (ce.getType().getNameWithoutPackage().equals(nameWithoutPackage)) {
                     return true;
@@ -505,11 +508,10 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
         return source;
     }
 
-
     private static class NewifyClassData {
         final String name;
         final ClassNode type;
-        List<ClassNode> types = null;
+        List<ClassNode> types;
 
         public NewifyClassData(final String name, final ClassNode type) {
             this.name = name;
@@ -524,6 +526,4 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
             types.add(additionalType);
         }
     }
-
-
 }
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java b/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java
index d65d9d4..df8f8b6 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java
@@ -45,7 +45,7 @@ import static org.codehaus.groovy.ast.ClassHelper.makeWithoutCaching;
  * @since 3.0.0
  */
 public abstract class AbstractExtensionMethodCache {
-    private final EvictableCache<ClassLoader, Map<String, List<MethodNode>>> cache = new StampedCommonCache<>(new WeakHashMap<>());
+    final EvictableCache<ClassLoader, Map<String, List<MethodNode>>> cache = new StampedCommonCache<>(new WeakHashMap<>());
 
     public Map<String, List<MethodNode>> get(ClassLoader loader) {
         return cache.getAndPut(loader, this::getMethodsFromClassLoader);
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index 10de207..5c2823d 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -162,31 +162,31 @@ public abstract class StaticTypeCheckingSupport {
     protected static final ExtensionMethodCache EXTENSION_METHOD_CACHE = ExtensionMethodCache.INSTANCE;
 
     protected static final Map<ClassNode, Integer> NUMBER_TYPES = Maps.of(
-            byte_TYPE, 0,
-            Byte_TYPE, 0,
-            short_TYPE, 1,
-            Short_TYPE, 1,
-            int_TYPE, 2,
+            byte_TYPE,    0,
+            Byte_TYPE,    0,
+            short_TYPE,   1,
+            Short_TYPE,   1,
+            int_TYPE,     2,
             Integer_TYPE, 2,
-            Long_TYPE, 3,
-            long_TYPE, 3,
-            float_TYPE, 4,
-            Float_TYPE, 4,
-            double_TYPE, 5,
-            Double_TYPE, 5
+            Long_TYPE,    3,
+            long_TYPE,    3,
+            float_TYPE,   4,
+            Float_TYPE,   4,
+            double_TYPE,  5,
+            Double_TYPE,  5
     );
 
     protected static final Map<String, Integer> NUMBER_OPS = Maps.of(
-            "plus", PLUS,
-            "minus", MINUS,
-            "multiply", MULTIPLY,
-            "div", DIVIDE,
-            "or", BITWISE_OR,
-            "and", BITWISE_AND,
-            "xor", BITWISE_XOR,
-            "mod", MOD,
-            "intdiv", INTDIV,
-            "leftShift", LEFT_SHIFT,
+            "plus",       PLUS,
+            "minus",      MINUS,
+            "multiply",   MULTIPLY,
+            "div",        DIVIDE,
+            "or",         BITWISE_OR,
+            "and",        BITWISE_AND,
+            "xor",        BITWISE_XOR,
+            "mod",        MOD,
+            "intdiv",     INTDIV,
+            "leftShift",  LEFT_SHIFT,
             "rightShift", RIGHT_SHIFT,
             "rightShiftUnsigned", RIGHT_SHIFT_UNSIGNED
     );
@@ -233,6 +233,10 @@ public abstract class StaticTypeCheckingSupport {
         }
     };
 
+    public static void clearExtensionMethodCache() {
+        EXTENSION_METHOD_CACHE.cache.clearAll();
+    }
+
     /**
      * Returns true for expressions of the form x[...]
      *
diff --git a/src/main/java/org/codehaus/groovy/transform/trait/TraitASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
index 8ca1c18..a12584c 100644
--- a/src/main/java/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
@@ -219,8 +219,8 @@ public class TraitASTTransformation extends AbstractASTTransformation implements
         for (final MethodNode methodNode : methods) {
             boolean declared = methodNode.getDeclaringClass() == cNode;
             if (declared) {
-                if (!methodNode.isSynthetic() && (methodNode.isProtected() || methodNode.getModifiers()==0)) {
-                    unit.addError(new SyntaxException("Cannot have protected/package private method in a trait (" + cNode.getName() + "#" + methodNode.getTypeDescriptor() + ")",
+                if (!methodNode.isSynthetic() && (methodNode.isProtected() || (!methodNode.isPrivate() && !methodNode.isPublic()))) {
+                    unit.addError(new SyntaxException("Cannot have protected/package-private method in a trait (" + cNode.getName() + "#" + methodNode.getTypeDescriptor() + ")",
                             methodNode.getLineNumber(), methodNode.getColumnNumber()));
                     return null;
                 }
diff --git a/src/main/java/org/codehaus/groovy/transform/trait/TraitReceiverTransformer.java b/src/main/java/org/codehaus/groovy/transform/trait/TraitReceiverTransformer.java
index 8cb68af..b1b965d 100644
--- a/src/main/java/org/codehaus/groovy/transform/trait/TraitReceiverTransformer.java
+++ b/src/main/java/org/codehaus/groovy/transform/trait/TraitReceiverTransformer.java
@@ -55,8 +55,9 @@ import java.util.List;
 /**
  * This expression transformer is used internally by the {@link org.codehaus.groovy.transform.trait.TraitASTTransformation
  * trait} AST transformation to change the receiver of a message on "this" into a static method call on the trait helper
- * class. <p></p>
- * In a nutshell, code like the following method definition in a trait:<p></p> <code>void foo() { this.bar() }</code> is
+ * class.
+ * <p>
+ * In a nutshell, code like the following method definition in a trait: <code>void foo() { this.bar() }</code> is
  * transformed into: <code>void foo() { TraitHelper$bar(this) }</code>
  *
  * @since 2.3.0
@@ -204,7 +205,7 @@ class TraitReceiverTransformer extends ClassCodeExpressionTransformer {
                 method,
                 ArgumentListExpression.EMPTY_ARGUMENTS
         );
-        mce.setSourcePosition(exp);
+        mce.setSourcePosition(exp instanceof PropertyExpression ? ((PropertyExpression) exp).getProperty() : exp);
         mce.setImplicitThis(false);
         return mce;
     }
@@ -349,7 +350,6 @@ class TraitReceiverTransformer extends ClassCodeExpressionTransformer {
         return transformed;
     }
 
-
     private Expression transformMethodCallOnThis(final MethodCallExpression call) {
         Expression method = call.getMethod();
         Expression arguments = call.getArguments();
diff --git a/src/test/gls/annotations/closures/AnnotationClosureThisObjectCallTest.groovy b/src/test/gls/annotations/closures/AnnotationClosureThisObjectCallTest.groovy
index 8761923..a3431e8 100644
--- a/src/test/gls/annotations/closures/AnnotationClosureThisObjectCallTest.groovy
+++ b/src/test/gls/annotations/closures/AnnotationClosureThisObjectCallTest.groovy
@@ -18,7 +18,8 @@
  */
 package gls.annotations.closures
 
-class AnnotationClosureThisObjectCallTest extends AnnotationClosureExhaustiveTestSupport {
+final class AnnotationClosureThisObjectCallTest extends AnnotationClosureExhaustiveTestSupport {
+
     Class getAnnotationClass() { AnnWithClassElement }
 
     Class getAnnotatedClass() { CallOnThisObject }
@@ -33,6 +34,7 @@ class AnnotationClosureThisObjectCallTest extends AnnotationClosureExhaustiveTes
 
 @AnnWithClassElement(elem = { this.answer() })
 class CallOnThisObject {
+
     @AnnWithClassElement(elem = { this.answer() })
     private aField
 
@@ -41,7 +43,8 @@ class CallOnThisObject {
 
     @AnnWithClassElement(elem = { this.answer() })
     def aMethod(@AnnWithClassElement(elem = { this.answer() }) aParam) {
+
         @AnnWithClassElement(elem = { this.answer() })
         def aLocal
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/org/codehaus/groovy/runtime/powerassert/AssertionTestUtil.groovy b/src/test/org/codehaus/groovy/runtime/powerassert/AssertionTestUtil.groovy
index 0aac26a..c7c677b 100644
--- a/src/test/org/codehaus/groovy/runtime/powerassert/AssertionTestUtil.groovy
+++ b/src/test/org/codehaus/groovy/runtime/powerassert/AssertionTestUtil.groovy
@@ -18,21 +18,26 @@
  */
 package org.codehaus.groovy.runtime.powerassert
 
+import groovy.transform.AutoFinal
 import org.junit.Assert
 
 /**
  * Utility methods for testing power assertions.
  */
+@AutoFinal
+final class AssertionTestUtil {
 
-abstract class AssertionTestUtil {
-    static fails(Closure assertion) {
+    private AssertionTestUtil() {
+    }
+
+    static fails(Closure<Void> assertion) {
         try {
             assertion.call();
             Assert.fail("assertion should have failed but didn't")
         } catch (PowerAssertionError expected) {}
     }
 
-    static isNotTransformed(Closure failingAssertion) {
+    static isNotTransformed(Closure<Void> failingAssertion) {
         try {
             failingAssertion()
             throw new RuntimeException("assertion should have failed but didn't")
@@ -42,7 +47,7 @@ abstract class AssertionTestUtil {
         }
     }
 
-    static isRendered(String expectedRendering, Closure failingAssertion) {
+    static isRendered(String expectedRendering, Closure<Void> failingAssertion) {
         try {
             failingAssertion.call();
             Assert.fail("assertion should have failed but didn't")


[groovy] 03/04: rework fixture

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d9eb08daf7e1cbf7552e4230ba6d3813f9c0ecda
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Dec 7 14:06:13 2019 -0600

    rework fixture
    
    (cherry picked from commit e39712dcf2f227333b83bc2be20672479bd73f45)
---
 .../src/spec/test/json/JsonBuilderTest.groovy      | 33 ++++++++++++++++------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/subprojects/groovy-json/src/spec/test/json/JsonBuilderTest.groovy b/subprojects/groovy-json/src/spec/test/json/JsonBuilderTest.groovy
index 4ada0d0..d05eedc 100644
--- a/subprojects/groovy-json/src/spec/test/json/JsonBuilderTest.groovy
+++ b/subprojects/groovy-json/src/spec/test/json/JsonBuilderTest.groovy
@@ -18,17 +18,32 @@
  */
 package json
 
-import groovy.test.GroovyTestCase
+import org.junit.BeforeClass
+import org.junit.Test
 
-class JsonBuilderTest extends GroovyTestCase {
+import static groovy.grape.Grape.resolve
+import static groovy.test.GroovyAssert.assertScript
 
+final class JsonBuilderTest {
+
+    @BeforeClass
+    static void setUpClass() {
+        // make sure files are installed locally
+        [
+            [groupId:'com.google.code.gson', artifactId:'gson', version:'2.3.1'],
+            [groupId:'net.javacrumbs.json-unit', artifactId:'json-unit', version:'1.5.6']
+        ].each { spec ->
+            resolve([autoDownload:true, classLoader:new GroovyClassLoader()], spec)
+        }
+    }
+
+    @Test
     void testJsonBuilder() {
         assertScript """
-            import groovy.json.*
-            @Grapes([
-                @Grab('com.google.code.gson:gson:2.3.1'), //required by json-unit
-                @Grab('net.javacrumbs.json-unit:json-unit:1.5.5')])
+            @Grab('com.google.code.gson:gson:2.3.1') // json-unit requires gson, jackson1, or jackson2
+            @Grab('net.javacrumbs.json-unit:json-unit:1.5.6')
             import net.javacrumbs.jsonunit.JsonAssert
+            import groovy.json.*
 
             // tag::json_string[]
             String carRecords = '''
@@ -48,14 +63,14 @@ class JsonBuilderTest extends GroovyTestCase {
                 }
             '''
             // end::json_string[]
-            
+
             // tag::json_builder[]
             JsonBuilder builder = new JsonBuilder()
             builder.records {
               car {
                     name 'HSV Maloo'
                     make 'Holden'
-                    year 2006 
+                    year 2006
                     country 'Australia'
                     record {
                         type 'speed'
@@ -65,7 +80,7 @@ class JsonBuilderTest extends GroovyTestCase {
             }
             String json = JsonOutput.prettyPrint(builder.toString())
             // end::json_builder[]
-            
+
             // tag::json_assert[]
             JsonAssert.assertJsonEquals(json, carRecords)
             // end::json_assert[]