Repository: groovy
Updated Branches:
  refs/heads/master 4ada9e66c -> d033d1ce5


http://git-wip-us.apache.org/repos/asf/groovy/blob/d033d1ce/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index c8e79bb..a6067c2 100644
--- 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -304,13 +304,13 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             if (returnStatement.getExpression() == ConstantExpression.NULL) 
return;
             if (isNullConstant(returnStatement.getExpression())) return;
             checkReturnType(returnStatement);
-            if (typeCheckingContext.getEnclosingClosure()!=null) {
+            if (typeCheckingContext.getEnclosingClosure() != null) {
                 addClosureReturnType(getType(returnStatement.getExpression()));
             } else if (typeCheckingContext.getEnclosingMethod() != null) {
             } else {
                 throw new GroovyBugError("Unexpected return statement at "
-                        + 
returnStatement.getLineNumber()+":"+returnStatement.getColumnNumber()
-                        + " "+returnStatement.getText());
+                        + returnStatement.getLineNumber() + ":" + 
returnStatement.getColumnNumber()
+                        + " " + returnStatement.getText());
             }
         }
     };
@@ -445,6 +445,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     /**
      * Test if a node is an inner class node, and if it is, then checks if the 
enclosing method is skipped.
+     *
      * @param node
      * @return true if the inner class node should be skipped
      */
@@ -466,7 +467,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     @SuppressWarnings("unchecked")
     private static void addPrivateFieldOrMethodAccess(Expression source, 
ClassNode cn, StaticTypesMarker type, ASTNode accessedMember) {
         Set<ASTNode> set = (Set<ASTNode>) cn.getNodeMetaData(type);
-        if (set==null) {
+        if (set == null) {
             set = new LinkedHashSet<ASTNode>();
             cn.putNodeMetaData(type, set);
         }
@@ -478,9 +479,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * Given a field node, checks if we are accessing or setting a private 
field from an inner class.
      */
     private void checkOrMarkPrivateAccess(Expression source, FieldNode fn, 
boolean lhsOfAssignment) {
-        if (fn!=null && Modifier.isPrivate(fn.getModifiers()) &&
-            (fn.getDeclaringClass() != 
typeCheckingContext.getEnclosingClassNode() || 
typeCheckingContext.getEnclosingClosure()!=null) &&
-            fn.getDeclaringClass().getModule() == 
typeCheckingContext.getEnclosingClassNode().getModule()) {
+        if (fn != null && Modifier.isPrivate(fn.getModifiers()) &&
+                (fn.getDeclaringClass() != 
typeCheckingContext.getEnclosingClassNode() || 
typeCheckingContext.getEnclosingClosure() != null) &&
+                fn.getDeclaringClass().getModule() == 
typeCheckingContext.getEnclosingClassNode().getModule()) {
             StaticTypesMarker marker = lhsOfAssignment ? 
StaticTypesMarker.PV_FIELDS_MUTATION : StaticTypesMarker.PV_FIELDS_ACCESS;
             addPrivateFieldOrMethodAccess(source, fn.getDeclaringClass(), 
marker, fn);
         }
@@ -490,7 +491,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * Given a method node, checks if we are calling a private method from an 
inner class.
      */
     private void checkOrMarkPrivateAccess(Expression source, MethodNode mn) {
-        if (mn==null) {
+        if (mn == null) {
             return;
         }
         ClassNode declaringClass = mn.getDeclaringClass();
@@ -499,7 +500,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             int mods = mn.getModifiers();
             boolean sameModule = declaringClass.getModule() == 
enclosingClassNode.getModule();
             String packageName = declaringClass.getPackageName();
-            if (packageName==null) {
+            if (packageName == null) {
                 packageName = "";
             }
             if ((Modifier.isPrivate(mods) && sameModule)) {
@@ -519,7 +520,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     private void checkSuperCallFromClosure(Expression call, MethodNode 
directCallTarget) {
         if (call instanceof MethodCallExpression && 
typeCheckingContext.getEnclosingClosure() != null) {
-            Expression objectExpression = 
((MethodCallExpression)call).getObjectExpression();
+            Expression objectExpression = ((MethodCallExpression) 
call).getObjectExpression();
             if (objectExpression instanceof VariableExpression) {
                 VariableExpression var = (VariableExpression) objectExpression;
                 if (var.isSuperExpression()) {
@@ -542,7 +543,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     private static ClassNode makeType(ClassNode cn, boolean usingClass) {
         if (usingClass) {
             ClassNode clazzType = CLASS_Type.getPlainNodeReference();
-            clazzType.setGenericsTypes(new GenericsType[] {new 
GenericsType(cn)});
+            clazzType.setGenericsTypes(new GenericsType[]{new 
GenericsType(cn)});
             return clazzType;
         } else {
             return cn;
@@ -600,7 +601,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             } else if ("delegate".equals(name)) {
                 DelegationMetadata md = 
getDelegationMetadata(enclosingClosure.getClosureExpression());
                 ClassNode type = typeCheckingContext.getEnclosingClassNode();
-                if (md!=null) type = md.getType();
+                if (md != null) type = md.getType();
                 storeType(vexp, type);
                 return;
             }
@@ -647,9 +648,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             vexp.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, previousIt);
             storeType(vexp, getType(pe));
             Object val = 
pe.getNodeMetaData(StaticTypesMarker.READONLY_PROPERTY);
-            if (val!=null) 
vexp.putNodeMetaData(StaticTypesMarker.READONLY_PROPERTY,val);
+            if (val != null) 
vexp.putNodeMetaData(StaticTypesMarker.READONLY_PROPERTY, val);
             val = pe.getNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER);
-            if (val!=null) 
vexp.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER,val);
+            if (val != null) 
vexp.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, val);
             return true;
         }
         return false;
@@ -661,7 +662,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     @Override
     public void visitPropertyExpression(final PropertyExpression pexp) {
-        if (visitPropertyExpressionSilent(pexp,pexp)) return;
+        if (visitPropertyExpressionSilent(pexp, pexp)) return;
 
         if (!extension.handleUnresolvedProperty(pexp)) {
             Expression objectExpression = pexp.getObjectExpression();
@@ -694,8 +695,8 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             storeType(expression, ClassHelper.make(IntRange.class));
         } else {
             ClassNode rangeType = 
ClassHelper.make(Range.class).getPlainNodeReference();
-            rangeType.setGenericsTypes(new GenericsType[] { new 
GenericsType(WideningCategories.lowestUpperBound(fromType, toType))});
-            storeType(expression,  rangeType);
+            rangeType.setGenericsTypes(new GenericsType[]{new 
GenericsType(WideningCategories.lowestUpperBound(fromType, toType))});
+            storeType(expression, rangeType);
         }
     }
 
@@ -724,16 +725,16 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     rType = UNKNOWN_PARAMETER_TYPE; // primitive types should 
be ignored as they will result in another failure
             }
             BinaryExpression reversedBinaryExpression = binX(rightExpression, 
expression.getOperation(), leftExpression);
-            ClassNode resultType = (op==KEYWORD_IN || op==COMPARE_NOT_IN)
-                    ?getResultType(rType,op,lType,reversedBinaryExpression)
-                    :getResultType(lType, op, rType, expression);
-            if (op==KEYWORD_IN || op==COMPARE_NOT_IN) {
+            ClassNode resultType = (op == KEYWORD_IN || op == COMPARE_NOT_IN)
+                    ? getResultType(rType, op, lType, reversedBinaryExpression)
+                    : getResultType(lType, op, rType, expression);
+            if (op == KEYWORD_IN || op == COMPARE_NOT_IN) {
                 // in case of the "in" operator, the receiver and the 
arguments are reversed
                 // so we use the reversedExpression and get the target method 
from it
                 storeTargetMethod(expression, (MethodNode) 
reversedBinaryExpression.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET));
             } else if (op == LEFT_SQUARE_BRACKET
                     && leftExpression instanceof VariableExpression
-                    && 
leftExpression.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE)==null) {
+                    && 
leftExpression.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE) == null) {
                 storeType(leftExpression, lType);
             }
             if (resultType == null) {
@@ -831,13 +832,13 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                         Parameter[] parameters = ((ClosureExpression) 
rightExpression).getParameters();
                         
leftExpression.putNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS, parameters);
                     } else if (rightExpression instanceof VariableExpression &&
-                            
((VariableExpression)rightExpression).getAccessedVariable() instanceof 
Expression &&
-                            
((Expression)((VariableExpression)rightExpression).getAccessedVariable()).getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS)!=null)
 {
-                        Variable targetVariable = 
findTargetVariable((VariableExpression)leftExpression);
+                            ((VariableExpression) 
rightExpression).getAccessedVariable() instanceof Expression &&
+                            ((Expression) ((VariableExpression) 
rightExpression).getAccessedVariable()).getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS)
 != null) {
+                        Variable targetVariable = 
findTargetVariable((VariableExpression) leftExpression);
                         if (targetVariable instanceof ASTNode) {
-                            ((ASTNode)targetVariable).putNodeMetaData(
-                                StaticTypesMarker.CLOSURE_ARGUMENTS,
-                                
((Expression)((VariableExpression)rightExpression).getAccessedVariable()).getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS));
+                            ((ASTNode) targetVariable).putNodeMetaData(
+                                    StaticTypesMarker.CLOSURE_ARGUMENTS,
+                                    ((Expression) ((VariableExpression) 
rightExpression).getAccessedVariable()).getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS));
                         }
                     }
                 }
@@ -857,10 +858,11 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     /**
      * Given a binary expression corresponding to an assignment, will check 
that the type of the RHS matches one
      * of the possible setters and if not, throw a type checking error.
-     * @param expression the assignment expression
-     * @param leftExpression left expression of the assignment
+     *
+     * @param expression      the assignment expression
+     * @param leftExpression  left expression of the assignment
      * @param rightExpression right expression of the assignment
-     * @param setterInfo possible setters
+     * @param setterInfo      possible setters
      * @return true if type checking passed
      */
     private boolean ensureValidSetter(final Expression expression, final 
Expression leftExpression, final Expression rightExpression, final SetterInfo 
setterInfo) {
@@ -877,7 +879,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         call.setImplicitThis(false);
         visitMethodCallExpression(call);
         MethodNode directSetterCandidate = 
call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
-        if (directSetterCandidate==null) {
+        if (directSetterCandidate == null) {
             // this may happen if there's a setter of type 
boolean/String/Class, and that we are using the property
             // notation AND that the RHS is not a boolean/String/Class
             for (MethodNode setter : setterInfo.setters) {
@@ -887,7 +889,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     call.setImplicitThis(false);
                     visitMethodCallExpression(call);
                     directSetterCandidate = 
call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
-                    if (directSetterCandidate!=null) {
+                    if (directSetterCandidate != null) {
                         break;
                     }
                 }
@@ -1080,8 +1082,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     private void addListAssignmentConstructorErrors(
             ClassNode leftRedirect, ClassNode leftExpressionType,
             ClassNode inferredRightExpressionType, Expression rightExpression,
-            Expression assignmentExpression)
-    {
+            Expression assignmentExpression) {
         // if left type is not a list but right type is a list, then we're in 
the case of a groovy
         // constructor type : Dimension d = [100,200]
         // In that case, more checks can be performed
@@ -1089,15 +1090,15 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             ArgumentListExpression argList = args(((ListExpression) 
rightExpression).getExpressions());
             ClassNode[] args = getArgumentTypes(argList);
             MethodNode methodNode = checkGroovyStyleConstructor(leftRedirect, 
args, assignmentExpression);
-            if (methodNode!=null) {
+            if (methodNode != null) {
                 
rightExpression.putNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET, 
methodNode);
             }
         } else if 
(!implementsInterfaceOrIsSubclassOf(inferredRightExpressionType, leftRedirect)
                 && 
implementsInterfaceOrIsSubclassOf(inferredRightExpressionType, LIST_TYPE)
                 && !isWildcardLeftHandSide(leftExpressionType)) {
-                if 
(!extension.handleIncompatibleAssignment(leftExpressionType, 
inferredRightExpressionType, assignmentExpression)) {
-                    addAssignmentError(leftExpressionType, 
inferredRightExpressionType, assignmentExpression);
-                }
+            if (!extension.handleIncompatibleAssignment(leftExpressionType, 
inferredRightExpressionType, assignmentExpression)) {
+                addAssignmentError(leftExpressionType, 
inferredRightExpressionType, assignmentExpression);
+            }
         }
     }
 
@@ -1125,7 +1126,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         if (hasRHSIncompleteGenericTypeInfo(wrappedRHS)) return;
 
         GenericsType gt = GenericsUtils.buildWildcardType(leftExpressionType);
-        if (    UNKNOWN_PARAMETER_TYPE.equals(wrappedRHS) ||
+        if (UNKNOWN_PARAMETER_TYPE.equals(wrappedRHS) ||
                 gt.isCompatibleWith(wrappedRHS) ||
                 isNullConstant(rightExpression)) return;
 
@@ -1148,8 +1149,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             final Expression leftExpression,
             final ClassNode leftExpressionType,
             final Expression rightExpression,
-            final ClassNode inferredRightExpressionTypeOrig)
-    {
+            final ClassNode inferredRightExpressionTypeOrig) {
         ClassNode inferredRightExpressionType = 
inferredRightExpressionTypeOrig;
         if (!typeCheckMultipleAssignmentAndContinue(leftExpression, 
rightExpression)) return;
 
@@ -1256,7 +1256,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         }
         List<MethodNode> constructorList = findMethod(node, "<init>", 
arguments);
         if (constructorList.isEmpty()) {
-            if (isBeingCompiled(node) && arguments.length==1 && 
LINKEDHASHMAP_CLASSNODE.equals(arguments[0])) {
+            if (isBeingCompiled(node) && arguments.length == 1 && 
LINKEDHASHMAP_CLASSNODE.equals(arguments[0])) {
                 // there will be a default hash map constructor added later
                 ConstructorNode cn = new ConstructorNode(Opcodes.ACC_PUBLIC, 
new Parameter[]{
                         new Parameter(LINKEDHASHMAP_CLASSNODE, "args")
@@ -1266,7 +1266,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 addStaticTypeError("No matching constructor found: " + node + 
toMethodParametersString("<init>", arguments), source);
                 return null;
             }
-        } else if (constructorList.size()>1) {
+        } else if (constructorList.size() > 1) {
             addStaticTypeError("Ambiguous constructor call " + node + 
toMethodParametersString("<init>", arguments), source);
             return null;
         }
@@ -1293,7 +1293,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * @param expr the expression for which an unknown field has been found
      * @param type the type of the expression (used as fallback type)
      * @return if temporary information is available and there's only one 
type, returns the temporary type class
-     *         otherwise falls back to the provided type class.
+     * otherwise falls back to the provided type class.
      */
     protected ClassNode findCurrentInstanceOfClass(final Expression expr, 
final ClassNode type) {
         if (!typeCheckingContext.temporaryIfBranchTypeInformation.empty()) {
@@ -1311,9 +1311,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * Checks whether a property exists on the receiver, or on any of the 
possible receiver classes (found in the
      * temporary type information table)
      *
-     * @param pexp             a property expression
-     * @param readMode         if true, look for property read, else for 
property set
-     * @param visitor          if not null, when the property node is found, 
visit it with the provided visitor
+     * @param pexp     a property expression
+     * @param readMode if true, look for property read, else for property set
+     * @param visitor  if not null, when the property node is found, visit it 
with the provided visitor
      * @return true if the property is defined in any of the possible receiver 
classes
      */
     protected boolean existsProperty(final PropertyExpression pexp, final 
boolean readMode, final ClassCodeVisitorSupport visitor) {
@@ -1389,7 +1389,8 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
                 FieldNode field = current.getDeclaredField(propertyName);
                 field = allowStaticAccessToMember(field, staticOnly);
-                if (storeField(field, isAttributeExpression, pexp, current, 
visitor, receiver.getData(), !readMode)) return true;
+                if (storeField(field, isAttributeExpression, pexp, current, 
visitor, receiver.getData(), !readMode))
+                    return true;
 
                 boolean isThisExpression = objectExpression instanceof 
VariableExpression
                         && ((VariableExpression) 
objectExpression).isThisExpression()
@@ -1469,7 +1470,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             List<ClassNode> dgmReceivers = new ArrayList<ClassNode>(2);
             dgmReceivers.add(testClass);
             if (isPrimitiveType(testClass)) 
dgmReceivers.add(getWrapper(testClass));
-            for (ClassNode dgmReceiver: dgmReceivers) {
+            for (ClassNode dgmReceiver : dgmReceivers) {
                 List<MethodNode> methods = 
findDGMMethodsByNameAndArguments(getTransformLoader(), dgmReceiver, "get" + 
capName, ClassNode.EMPTY_ARRAY);
                 for (MethodNode m : 
findDGMMethodsByNameAndArguments(getTransformLoader(), dgmReceiver, "is" + 
capName, ClassNode.EMPTY_ARRAY)) {
                     if (Boolean_TYPE.equals(getWrapper(m.getReturnType()))) 
methods.add(m);
@@ -1493,10 +1494,11 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         for (Receiver<String> receiver : receivers) {
             ClassNode testClass = receiver.getType();
             ClassNode propertyType = 
getTypeForMapPropertyExpression(testClass, objectExpressionType, pexp);
-            if (propertyType==null) propertyType = 
getTypeForListPropertyExpression(testClass, objectExpressionType, pexp);
-            if (propertyType==null) propertyType = 
getTypeForSpreadExpression(testClass, objectExpressionType, pexp);
-            if (propertyType==null) continue;
-            if (visitor!=null) {
+            if (propertyType == null)
+                propertyType = getTypeForListPropertyExpression(testClass, 
objectExpressionType, pexp);
+            if (propertyType == null) propertyType = 
getTypeForSpreadExpression(testClass, objectExpressionType, pexp);
+            if (propertyType == null) continue;
+            if (visitor != null) {
                 // todo : type inference on maps and lists, if possible
                 PropertyNode node = new PropertyNode(propertyName, 
Opcodes.ACC_PUBLIC, propertyType, receiver.getType(), null, null, null);
                 node.setDeclaringClass(receiver.getType());
@@ -1504,7 +1506,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             }
             storeType(pexp, propertyType);
             String delegationData = receiver.getData();
-            if (delegationData!=null) 
pexp.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, delegationData);
+            if (delegationData != null) 
pexp.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, delegationData);
             return true;
         }
         return foundGetterOrSetter;
@@ -1527,12 +1529,12 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         if (!implementsInterfaceOrIsSubclassOf(callType, Iterator_TYPE)) 
return null;
         GenericsType[] types = callType.getGenericsTypes();
         ClassNode contentType = OBJECT_TYPE;
-        if (types!=null && types.length==1) contentType = types[0].getType();
+        if (types != null && types.length == 1) contentType = 
types[0].getType();
         PropertyExpression subExp = new PropertyExpression(varX("{}", 
contentType), pexp.getPropertyAsString());
         AtomicReference<ClassNode> result = new AtomicReference<ClassNode>();
         if (existsProperty(subExp, true, new PropertyLookupVisitor(result))) {
             ClassNode intf = LIST_TYPE.getPlainNodeReference();
-            intf.setGenericsTypes(new GenericsType[] { new 
GenericsType(getWrapper(result.get()))});
+            intf.setGenericsTypes(new GenericsType[]{new 
GenericsType(getWrapper(result.get()))});
             return intf;
         }
         return null;
@@ -1542,14 +1544,14 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         if (!implementsInterfaceOrIsSubclassOf(testClass, LIST_TYPE)) return 
null;
         ClassNode intf = GenericsUtils.parameterizeType(objectExpressionType, 
LIST_TYPE.getPlainNodeReference());
         GenericsType[] types = intf.getGenericsTypes();
-        if (types==null || types.length!=1) return OBJECT_TYPE;
+        if (types == null || types.length != 1) return OBJECT_TYPE;
 
         PropertyExpression subExp = new PropertyExpression(varX("{}", 
types[0].getType()), pexp.getPropertyAsString());
         AtomicReference<ClassNode> result = new AtomicReference<ClassNode>();
         if (existsProperty(subExp, true, new PropertyLookupVisitor(result))) {
             intf = LIST_TYPE.getPlainNodeReference();
             ClassNode itemType = result.get();
-            intf.setGenericsTypes(new GenericsType[] { new 
GenericsType(wrapTypeIfNecessary(itemType))});
+            intf.setGenericsTypes(new GenericsType[]{new 
GenericsType(wrapTypeIfNecessary(itemType))});
             return intf;
         }
         return null;
@@ -1558,7 +1560,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     private ClassNode getTypeForMapPropertyExpression(ClassNode testClass, 
ClassNode objectExpressionType, PropertyExpression pexp) {
         if (!implementsInterfaceOrIsSubclassOf(testClass, MAP_TYPE)) return 
null;
         ClassNode intf;
-        if (objectExpressionType.getGenericsTypes()!=null) {
+        if (objectExpressionType.getGenericsTypes() != null) {
             intf = GenericsUtils.parameterizeType(objectExpressionType, 
MAP_TYPE.getPlainNodeReference());
         } else {
             intf = MAP_TYPE.getPlainNodeReference();
@@ -1590,7 +1592,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     /**
      * This method is used to filter search results in which null means "no 
match",
      * to filter out illegal access to instance members from a static context.
-     *
+     * <p>
      * Return null if the given member is not static, but we want to access in
      * a static way (staticOnly=true). If we want to access in a non-static way
      * we always return the member, since then access to static members and
@@ -1604,9 +1606,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         if (member instanceof Variable) {
             Variable v = (Variable) member;
             isStatic = Modifier.isStatic(v.getModifiers());
-        } else if (member instanceof List)  {
+        } else if (member instanceof List) {
             List<MethodNode> list = (List<MethodNode>) member;
-            if (list.size()==1) {
+            if (list.size() == 1) {
                 return (T) 
Collections.singletonList(allowStaticAccessToMember(list.get(0), staticOnly));
             }
             return (T) Collections.emptyList();
@@ -1620,7 +1622,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     private void storeWithResolve(ClassNode typeToResolve, ClassNode receiver, 
ClassNode declaringClass, boolean isStatic, PropertyExpression 
expressionToStoreOn) {
         ClassNode type = typeToResolve;
-        if (getGenericsWithoutArray(type)!=null) {
+        if (getGenericsWithoutArray(type) != null) {
             Map<String, GenericsType> resolvedPlaceholders = 
resolvePlaceHoldersFromDeclaration(receiver, declaringClass, null, isStatic);
             type = resolveGenericsWithContext(resolvedPlaceholders, type);
         }
@@ -1629,11 +1631,11 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     private boolean storeField(FieldNode field, boolean 
returnTrueIfFieldExists, PropertyExpression expressionToStoreOn, ClassNode 
receiver, ClassCodeVisitorSupport visitor, String delegationData, boolean 
lhsOfAssignment) {
-        if (field==null || !returnTrueIfFieldExists) return false;
+        if (field == null || !returnTrueIfFieldExists) return false;
         if (visitor != null) visitor.visitField(field);
         storeWithResolve(field.getOriginType(), receiver, 
field.getDeclaringClass(), field.isStatic(), expressionToStoreOn);
         checkOrMarkPrivateAccess(expressionToStoreOn, field, lhsOfAssignment);
-        if (delegationData!=null) {
+        if (delegationData != null) {
             
expressionToStoreOn.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, 
delegationData);
         }
         return true;
@@ -1643,7 +1645,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         if (propertyNode == null) return false;
         if (visitor != null) visitor.visitProperty(propertyNode);
         storeWithResolve(propertyNode.getOriginType(), receiver, 
propertyNode.getDeclaringClass(), propertyNode.isStatic(), expressionToStoreOn);
-        if (delegationData!=null) {
+        if (delegationData != null) {
             
expressionToStoreOn.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, 
delegationData);
         }
         return true;
@@ -1652,7 +1654,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     protected void storeInferredTypeForPropertyExpression(final 
PropertyExpression pexp, final ClassNode flatInferredType) {
         if (pexp.isSpreadSafe()) {
             ClassNode list = LIST_TYPE.getPlainNodeReference();
-            list.setGenericsTypes(new GenericsType[] {
+            list.setGenericsTypes(new GenericsType[]{
                     new GenericsType(flatInferredType)
             });
             storeType(pexp, list);
@@ -1674,7 +1676,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         String capName = MetaClassHelper.capitalize(propertyName);
         boolean isAttributeExpression = pexp instanceof AttributeExpression;
 
-        for (Receiver<String> receiver: receivers) {
+        for (Receiver<String> receiver : receivers) {
             ClassNode testClass = receiver.getType();
             LinkedList<ClassNode> queue = new LinkedList<ClassNode>();
             queue.add(testClass);
@@ -1851,7 +1853,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             resultType = PATTERN_TYPE;
         } else {
             MethodNode mn = findMethodOrFail(expression, type, 
"bitwiseNegate");
-            if (mn!=null) {
+            if (mn != null) {
                 resultType = mn.getReturnType();
             } else {
                 resultType = OBJECT_TYPE;
@@ -1911,7 +1913,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     if (node != null) {
                         storeTargetMethod(origin, node);
                         storeType(origin,
-                                
isPostfix?exprType:getMathWideningClassNode(exprType));
+                                isPostfix ? exprType : 
getMathWideningClassNode(exprType));
                         return;
                     }
                 }
@@ -1937,7 +1939,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         MethodNode node = findMethodOrFail(innerExpression, exprType, name);
         if (node != null) {
             storeTargetMethod(origin, node);
-            storeType(origin,  
isPostfix?exprType:inferReturnTypeGenerics(exprType, node, 
ArgumentListExpression.EMPTY_ARGUMENTS));
+            storeType(origin, isPostfix ? exprType : 
inferReturnTypeGenerics(exprType, node, 
ArgumentListExpression.EMPTY_ARGUMENTS));
         }
     }
 
@@ -1981,7 +1983,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     protected ClassNode checkReturnType(final ReturnStatement statement) {
         Expression expression = statement.getExpression();
         ClassNode type = getType(expression);
-        if (typeCheckingContext.getEnclosingClosure()!=null) {
+        if (typeCheckingContext.getEnclosingClosure() != null) {
             return type;
         }
         // handle instanceof cases
@@ -1989,7 +1991,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             type = 
expression.getNodeMetaData(StaticTypesMarker.INFERRED_RETURN_TYPE);
         }
         MethodNode enclosingMethod = typeCheckingContext.getEnclosingMethod();
-        if (enclosingMethod != null && 
typeCheckingContext.getEnclosingClosure()==null) {
+        if (enclosingMethod != null && 
typeCheckingContext.getEnclosingClosure() == null) {
             if (!enclosingMethod.isVoidMethod()
                     && !type.equals(void_WRAPPER_TYPE)
                     && !type.equals(VOID_TYPE)
@@ -2044,14 +2046,13 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         checkForbiddenSpreadArgument(argumentList);
 
         ClassNode[] args = getArgumentTypes(argumentList);
-        if (    args.length>0 &&
-                typeCheckingContext.getEnclosingClosure()!=null &&
+        if (args.length > 0 &&
+                typeCheckingContext.getEnclosingClosure() != null &&
                 argumentList.getExpression(0) instanceof VariableExpression &&
                 ((VariableExpression) 
argumentList.getExpression(0)).isThisExpression() &&
                 call.getType() instanceof InnerClassNode &&
                 call.getType().getOuterClass().equals(args[0]) &&
-                !call.getType().isStaticClass())
-        {
+                !call.getType().isStaticClass()) {
             args[0] = CLOSURE_TYPE;
         }
 
@@ -2117,11 +2118,11 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         ClassNode[] ret = new ClassNode[arglist.size()];
         for (int i = 0; i < arglist.size(); i++) {
             Expression exp = arglist.get(i);
-                if (isNullConstant(exp)) {
-                    ret[i] = UNKNOWN_PARAMETER_TYPE;
-                } else {
-                    ret[i] = getInferredTypeFromTempInfo(exp, getType(exp));
-                }
+            if (isNullConstant(exp)) {
+                ret[i] = UNKNOWN_PARAMETER_TYPE;
+            } else {
+                ret[i] = getInferredTypeFromTempInfo(exp, getType(exp));
+            }
         }
         return ret;
     }
@@ -2144,7 +2145,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 }
                 if (arr.isEmpty()) {
                     result = ClassHelper.OBJECT_TYPE.getPlainNodeReference();
-                } else if (arr.size()==1) {
+                } else if (arr.size() == 1) {
                     result = arr.get(0);
                 } else {
                     result = new 
UnionTypeClassNode(arr.toArray(ClassNode.EMPTY_ARRAY));
@@ -2178,7 +2179,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         // perform visit
         typeCheckingContext.pushEnclosingClosureExpression(expression);
         DelegationMetadata dmd = getDelegationMetadata(expression);
-        if (dmd ==null) {
+        if (dmd == null) {
             typeCheckingContext.delegationMetadata = new DelegationMetadata(
                     typeCheckingContext.getEnclosingClassNode(), 
Closure.OWNER_FIRST, typeCheckingContext.delegationMetadata
             );
@@ -2211,7 +2212,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         restoreVariableExpressionMetadata(typesBeforeVisit);
         typeCheckingContext.isInStaticContext = oldStaticContext;
         Parameter[] parameters = expression.getParameters();
-        if (parameters!=null) {
+        if (parameters != null) {
             for (Parameter parameter : parameters) {
                 
typeCheckingContext.controlStructureVariables.remove(parameter);
             }
@@ -2292,7 +2293,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             return;
         }
         for (Parameter parameter : node.getParameters()) {
-            if (parameter.getInitialExpression()!=null) {
+            if (parameter.getInitialExpression() != null) {
                 parameter.getInitialExpression().visit(this);
             }
         }
@@ -2307,7 +2308,8 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         // we must not visit a method which used dynamic dispatch.
         // We do not check for an annotation because some other AST 
transformations
         // may use this visitor without the annotation being explicitly set
-        if (!typeCheckingContext.methodsToBeVisited.isEmpty() && 
!typeCheckingContext.methodsToBeVisited.contains(node)) return;
+        if (!typeCheckingContext.methodsToBeVisited.isEmpty() && 
!typeCheckingContext.methodsToBeVisited.contains(node))
+            return;
 
         // alreadyVisitedMethods prevents from visiting the same method 
multiple times
         // and prevents from infinite loops
@@ -2321,7 +2323,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             typeCheckingContext.isInStaticContext = node.isStatic();
             super.visitMethod(node);
             for (Parameter parameter : node.getParameters()) {
-                if (parameter.getInitialExpression()!=null) {
+                if (parameter.getInitialExpression() != null) {
                     parameter.getInitialExpression().visit(this);
                 }
             }
@@ -2399,7 +2401,8 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             for (Receiver<String> currentReceiver : receivers) {
                 mn = findMethod(currentReceiver.getType(), name, args);
                 if (!mn.isEmpty()) {
-                    if (mn.size() == 1) 
typeCheckMethodsWithGenericsOrFail(currentReceiver.getType(), args, mn.get(0), 
call);
+                    if (mn.size() == 1)
+                        
typeCheckMethodsWithGenericsOrFail(currentReceiver.getType(), args, mn.get(0), 
call);
                     chosenReceiver = currentReceiver;
                     break;
                 }
@@ -2428,7 +2431,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     addAmbiguousErrorMessage(mn, name, args, call);
                 }
                 if (!callArgsVisited) {
-                    visitMethodCallArguments(receiver, argumentList, true, 
(MethodNode)call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET));
+                    visitMethodCallArguments(receiver, argumentList, true, 
(MethodNode) call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET));
                 }
             }
         } finally {
@@ -2437,9 +2440,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     /**
-     * @deprecated this method is unused, replaced with {@link DelegatesTo} 
inference.
      * @param callArguments
      * @param receiver
+     * @deprecated this method is unused, replaced with {@link DelegatesTo} 
inference.
      */
     @Deprecated
     protected void checkClosureParameters(final Expression callArguments, 
final ClassNode receiver) {
@@ -2474,7 +2477,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     protected void visitMethodCallArguments(final ClassNode receiver, 
ArgumentListExpression arguments, boolean visitClosures, final MethodNode 
selectedMethod) {
-        Parameter[] params = 
selectedMethod!=null?selectedMethod.getParameters(): Parameter.EMPTY_ARRAY;
+        Parameter[] params = selectedMethod != null ? 
selectedMethod.getParameters() : Parameter.EMPTY_ARRAY;
         List<Expression> expressions = new 
LinkedList<Expression>(arguments.getExpressions());
         if (selectedMethod instanceof ExtensionMethodNode) {
             params = ((ExtensionMethodNode) 
selectedMethod).getExtensionMethodNode().getParameters();
@@ -2486,19 +2489,19 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             final Expression expression = expressions.get(i);
             if (visitClosures && expression instanceof ClosureExpression
                     || !visitClosures && !(expression instanceof 
ClosureExpression)) {
-                if (i<params.length && visitClosures) {
+                if (i < params.length && visitClosures) {
                     Parameter param = params[i];
-                    checkClosureWithDelegatesTo(receiver, selectedMethod, 
newArgs,params , expression, param);
+                    checkClosureWithDelegatesTo(receiver, selectedMethod, 
newArgs, params, expression, param);
                     if (selectedMethod instanceof ExtensionMethodNode) {
-                        if (i>0) {
-                            inferClosureParameterTypes(receiver, arguments, 
(ClosureExpression)expression, param, selectedMethod);
+                        if (i > 0) {
+                            inferClosureParameterTypes(receiver, arguments, 
(ClosureExpression) expression, param, selectedMethod);
                         }
                     } else {
                         inferClosureParameterTypes(receiver, newArgs, 
(ClosureExpression) expression, param, selectedMethod);
                     }
                 }
                 expression.visit(this);
-                if 
(expression.getNodeMetaData(StaticTypesMarker.DELEGATION_METADATA)!=null) {
+                if 
(expression.getNodeMetaData(StaticTypesMarker.DELEGATION_METADATA) != null) {
                     
expression.removeNodeMetaData(StaticTypesMarker.DELEGATION_METADATA);
                 }
             }
@@ -2514,13 +2517,13 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      *
      * @param receiver
      * @param arguments
-     * @param expression a closure expression for which the argument types 
should be inferred
-     * @param param the parameter where to look for a {@link 
groovy.transform.stc.ClosureParams} annotation.
+     * @param expression     a closure expression for which the argument types 
should be inferred
+     * @param param          the parameter where to look for a {@link 
groovy.transform.stc.ClosureParams} annotation.
      * @param selectedMethod the method accepting a closure
      */
     protected void inferClosureParameterTypes(final ClassNode receiver, final 
Expression arguments, final ClosureExpression expression, final Parameter 
param, final MethodNode selectedMethod) {
         List<AnnotationNode> annotations = 
param.getAnnotations(CLOSUREPARAMS_CLASSNODE);
-        if (annotations!=null && !annotations.isEmpty()) {
+        if (annotations != null && !annotations.isEmpty()) {
             for (AnnotationNode annotation : annotations) {
                 Expression hintClass = annotation.getMember("value");
                 Expression options = annotation.getMember("options");
@@ -2550,7 +2553,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
         // First we try to get as much information about the declaration
         // class through the receiver
-        Map<String,GenericsType> targetMethodDeclarationClassConnections = new 
HashMap<String,GenericsType>();
+        Map<String, GenericsType> targetMethodDeclarationClassConnections = 
new HashMap<String, GenericsType>();
         extractGenericsConnections(targetMethodDeclarationClassConnections, 
receiver, receiver.redirect());
         // then we use the method with the SAM parameter to get more 
information about the declaration
         Parameter[] parametersOfMethodContainingSAM = 
methodWithSAMParameter.getParameters();
@@ -2571,7 +2574,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         // to replace the generics in the SAM type parameter of the target
         // method and than that to make the connections to the SAM type 
generics
         ClassNode paramTypeWithReceiverInformation = 
applyGenericsContext(targetMethodDeclarationClassConnections, 
param.getOriginType());
-        Map<String,GenericsType> SAMTypeConnections = new 
HashMap<String,GenericsType>();
+        Map<String, GenericsType> SAMTypeConnections = new HashMap<String, 
GenericsType>();
         ClassNode classForSAM = paramTypeWithReceiverInformation.redirect();
         extractGenericsConnections(SAMTypeConnections, 
paramTypeWithReceiverInformation, classForSAM);
 
@@ -2580,12 +2583,12 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         MethodNode methodForSAM = findSAM(classForSAM);
         ClassNode[] parameterTypesForSAM = 
extractTypesFromParameters(methodForSAM.getParameters());
         ClassNode[] blockParameterTypes = (ClassNode[]) 
openBlock.getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS);
-        if (blockParameterTypes==null) {
+        if (blockParameterTypes == null) {
             Parameter[] p = openBlock.getParameters();
             if (p == null) {
                 // zero parameter closure e.g. { -> println 'no args' }
                 blockParameterTypes = ClassNode.EMPTY_ARRAY;
-            } else if (p.length==0 && parameterTypesForSAM.length!=0) {
+            } else if (p.length == 0 && parameterTypesForSAM.length != 0) {
                 // implicit it
                 blockParameterTypes = parameterTypesForSAM;
             } else {
@@ -2599,13 +2602,13 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 }
             }
         }
-        for (int i=0; i<blockParameterTypes.length; i++) {
+        for (int i = 0; i < blockParameterTypes.length; i++) {
             extractGenericsConnections(SAMTypeConnections, 
blockParameterTypes[i], typeOrNull(parameterTypesForSAM, i));
         }
 
         // and finally we apply the generics information to the parameters and
         // store the type of parameter and block type as meta information
-        for (int i=0; i<blockParameterTypes.length; i++) {
+        for (int i = 0; i < blockParameterTypes.length; i++) {
             ClassNode resolvedParameter =
                     applyGenericsContext(SAMTypeConnections, 
typeOrNull(parameterTypesForSAM, i));
             blockParameterTypes[i] = resolvedParameter;
@@ -2626,7 +2629,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             Class<? extends ClosureSignatureHint> hint = (Class<? extends 
ClosureSignatureHint>) transformLoader.loadClass(hintClass.getText());
             ClosureSignatureHint hintInstance = hint.newInstance();
             closureSignatures = hintInstance.getClosureSignatures(
-                    selectedMethod instanceof ExtensionMethodNode 
?((ExtensionMethodNode) selectedMethod).getExtensionMethodNode():selectedMethod,
+                    selectedMethod instanceof ExtensionMethodNode ? 
((ExtensionMethodNode) selectedMethod).getExtensionMethodNode() : 
selectedMethod,
                     typeCheckingContext.source,
                     typeCheckingContext.compilationUnit,
                     convertToStringArray(options), expression);
@@ -2667,7 +2670,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     private ClassLoader getTransformLoader() {
         CompilationUnit compilationUnit = 
typeCheckingContext.getCompilationUnit();
-        return 
compilationUnit!=null?compilationUnit.getTransformLoader():getSourceUnit().getClassLoader();
+        return compilationUnit != null ? compilationUnit.getTransformLoader() 
: getSourceUnit().getClassLoader();
     }
 
     private void doInferClosureParameterTypes(final ClassNode receiver, final 
Expression arguments, final ClosureExpression expression, final MethodNode 
selectedMethod, final Expression hintClass, Expression resolverClass, final 
Expression options) {
@@ -2688,7 +2691,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 candidates.add(inferred);
             }
         }
-        if (candidates.size()>1) {
+        if (candidates.size() > 1) {
             Iterator<ClassNode[]> candIt = candidates.iterator();
             while (candIt.hasNext()) {
                 ClassNode[] inferred = candIt.next();
@@ -2697,10 +2700,10 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     Parameter closureParam = closureParams[i];
                     final ClassNode originType = closureParam.getOriginType();
                     ClassNode inferredType;
-                    if (i<inferred.length-1 || 
inferred.length==closureParams.length) {
+                    if (i < inferred.length - 1 || inferred.length == 
closureParams.length) {
                         inferredType = inferred[i];
                     } else { // vargs?
-                        ClassNode lastArgInferred = 
inferred[inferred.length-1];
+                        ClassNode lastArgInferred = inferred[inferred.length - 
1];
                         if (lastArgInferred.isArray()) {
                             inferredType = lastArgInferred.getComponentType();
                         } else {
@@ -2708,7 +2711,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                             continue;
                         }
                     }
-                    if (!typeCheckMethodArgumentWithGenerics(originType, 
inferredType, i== length -1)) {
+                    if (!typeCheckMethodArgumentWithGenerics(originType, 
inferredType, i == length - 1)) {
                         candIt.remove();
                     }
                 }
@@ -2716,13 +2719,13 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             if (candidates.size() > 1 && resolverClass instanceof 
ClassExpression) {
                 candidates = resolveWithResolver(candidates, receiver, 
arguments, expression, selectedMethod, resolverClass, options);
             }
-            if (candidates.size()>1) {
+            if (candidates.size() > 1) {
                 addError("Ambiguous prototypes for closure. More than one 
target method matches. Please use explicit argument types.", expression);
             }
         }
-        if (candidates.size()==1) {
+        if (candidates.size() == 1) {
             ClassNode[] inferred = candidates.get(0);
-            if (closureParams.length==0 && inferred.length==1) {
+            if (closureParams.length == 0 && inferred.length == 1) {
                 
expression.putNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS, inferred);
             } else {
                 final int length = closureParams.length;
@@ -2730,15 +2733,15 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     Parameter closureParam = closureParams[i];
                     final ClassNode originType = closureParam.getOriginType();
                     ClassNode inferredType = OBJECT_TYPE;
-                    if (i<inferred.length-1 || 
inferred.length==closureParams.length) {
+                    if (i < inferred.length - 1 || inferred.length == 
closureParams.length) {
                         inferredType = inferred[i];
                     } else { // vargs?
-                            ClassNode lastArgInferred = 
inferred[inferred.length-1];
-                            if (lastArgInferred.isArray()) {
-                                inferredType = 
lastArgInferred.getComponentType();
-                            } else {
-                                addError("Incorrect number of parameters. 
Expected "+inferred.length+" but found "+closureParams.length, expression);
-                            }
+                        ClassNode lastArgInferred = inferred[inferred.length - 
1];
+                        if (lastArgInferred.isArray()) {
+                            inferredType = lastArgInferred.getComponentType();
+                        } else {
+                            addError("Incorrect number of parameters. Expected 
" + inferred.length + " but found " + closureParams.length, expression);
+                        }
                     }
                     boolean lastArg = i == length - 1;
 
@@ -2747,7 +2750,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                             inferredType = originType;
                         }
                     } else if 
(!typeCheckMethodArgumentWithGenerics(originType, inferredType, lastArg)) {
-                        addError("Expected parameter of type "+ 
inferredType.toString(false)+" but got "+originType.toString(false), 
closureParam.getType());
+                        addError("Expected parameter of type " + 
inferredType.toString(false) + " but got " + originType.toString(false), 
closureParam.getType());
                     }
 
                     
typeCheckingContext.controlStructureVariables.put(closureParam, inferredType);
@@ -2771,7 +2774,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 dummyMN.getParameters(),
                 dummyMN.getExceptions(),
                 EmptyStatement.INSTANCE
-                );
+        );
         dummyMN.setDeclaringClass(selectedMethod.getDeclaringClass());
         dummyMN.setGenericsTypes(selectedMethod.getGenericsTypes());
         if (selectedMethod instanceof ExtensionMethodNode) {
@@ -2785,7 +2788,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     orig.getExceptions(),
                     EmptyStatement.INSTANCE,
                     orig.isStaticExtension()
-                    );
+            );
             dummyMN.setDeclaringClass(orig.getDeclaringClass());
             dummyMN.setGenericsTypes(orig.getGenericsTypes());
         }
@@ -2801,6 +2804,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     /**
      * Given a GenericsType instance, returns a ClassNode which can be used as 
an inferred type.
+     *
      * @param genericsType a {@link org.codehaus.groovy.ast.GenericsType} 
representing either a type, a placeholder or a wildcard
      * @return a class node usable as an inferred type
      */
@@ -2810,11 +2814,11 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             value = OBJECT_TYPE;
         }
         ClassNode lowerBound = genericsType.getLowerBound();
-        if (lowerBound !=null) {
+        if (lowerBound != null) {
             value = lowerBound;
         } else {
             ClassNode[] upperBounds = genericsType.getUpperBounds();
-            if (upperBounds !=null) {
+            if (upperBounds != null) {
                 value = 
WideningCategories.lowestUpperBound(Arrays.asList(upperBounds));
             }
         }
@@ -2822,11 +2826,11 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     private static String[] convertToStringArray(final Expression options) {
-        if (options==null) {
+        if (options == null) {
             return EMPTY_STRING_ARRAY;
         }
         if (options instanceof ConstantExpression) {
-            return new String[] { options.getText() };
+            return new String[]{options.getText()};
         }
         if (options instanceof ListExpression) {
             List<Expression> list = ((ListExpression) 
options).getExpressions();
@@ -2836,7 +2840,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             }
             return result.toArray(new String[0]);
         }
-        throw new IllegalArgumentException("Unexpected options for 
@ClosureParams:"+options);
+        throw new IllegalArgumentException("Unexpected options for 
@ClosureParams:" + options);
     }
 
     private void checkClosureWithDelegatesTo(final ClassNode receiver,
@@ -2846,7 +2850,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                                              final Expression expression,
                                              final Parameter param) {
         List<AnnotationNode> annotations = param.getAnnotations(DELEGATES_TO);
-        if (annotations!=null && !annotations.isEmpty()) {
+        if (annotations != null && !annotations.isEmpty()) {
             for (AnnotationNode annotation : annotations) {
                 // in theory, there can only be one annotation of that type
                 Expression value = annotation.getMember("value");
@@ -2854,17 +2858,17 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 Expression genericTypeIndex = 
annotation.getMember("genericTypeIndex");
                 Expression type = annotation.getMember("type");
                 Integer stInt = Closure.OWNER_FIRST;
-                if (strategy!=null) {
-                    stInt = (Integer) 
evaluateExpression(castX(ClassHelper.Integer_TYPE,strategy), 
typeCheckingContext.source.getConfiguration());
+                if (strategy != null) {
+                    stInt = (Integer) 
evaluateExpression(castX(ClassHelper.Integer_TYPE, strategy), 
typeCheckingContext.source.getConfiguration());
                 }
                 if (value instanceof ClassExpression && 
!value.getType().equals(DELEGATES_TO_TARGET)) {
-                    if (genericTypeIndex!=null) {
-                        addStaticTypeError("Cannot use 
@DelegatesTo(genericTypeIndex="+genericTypeIndex.getText()
-                                +") without @DelegatesTo.Target because 
generic argument types are not available at runtime", value);
+                    if (genericTypeIndex != null) {
+                        addStaticTypeError("Cannot use 
@DelegatesTo(genericTypeIndex=" + genericTypeIndex.getText()
+                                + ") without @DelegatesTo.Target because 
generic argument types are not available at runtime", value);
                     }
                     // temporarily store the delegation strategy and the 
delegate type
                     
expression.putNodeMetaData(StaticTypesMarker.DELEGATION_METADATA, new 
DelegationMetadata(value.getType(), stInt, 
typeCheckingContext.delegationMetadata));
-                } else if (type!=null && !"".equals(type.getText()) && type 
instanceof ConstantExpression) {
+                } else if (type != null && !"".equals(type.getText()) && type 
instanceof ConstantExpression) {
                     String typeString = type.getText();
                     ClassNode[] resolved = 
GenericsUtils.parseClassNodesFromString(
                             typeString,
@@ -2873,9 +2877,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                             mn,
                             type
                     );
-                    if (resolved!=null) {
-                        if (resolved.length==1) {
-                            resolved = resolveGenericsFromTypeHint(receiver, 
arguments, mn, resolved );
+                    if (resolved != null) {
+                        if (resolved.length == 1) {
+                            resolved = resolveGenericsFromTypeHint(receiver, 
arguments, mn, resolved);
                             
expression.putNodeMetaData(StaticTypesMarker.DELEGATION_METADATA, new 
DelegationMetadata(resolved[0], stInt, typeCheckingContext.delegationMetadata));
                         } else {
                             addStaticTypeError("Incorrect type hint found in 
method " + (mn), type);
@@ -2885,7 +2889,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     final List<Expression> expressions = 
arguments.getExpressions();
                     final int expressionsSize = expressions.size();
                     Expression parameter = annotation.getMember("target");
-                    String parameterName = parameter instanceof 
ConstantExpression ?parameter.getText():"";
+                    String parameterName = parameter instanceof 
ConstantExpression ? parameter.getText() : "";
                     // todo: handle vargs!
                     for (int j = 0, paramsLength = params.length; j < 
paramsLength; j++) {
                         final Parameter methodParam = params[j];
@@ -2902,19 +2906,19 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                                         int gti = 
Integer.parseInt(genericTypeIndex.getText());
                                         ClassNode paramType = 
methodParam.getType(); // type annotated with @DelegatesTo.Target
                                         GenericsType[] genericsTypes = 
paramType.getGenericsTypes();
-                                        if (genericsTypes==null) {
-                                            addStaticTypeError("Cannot use 
@DelegatesTo(genericTypeIndex="+genericTypeIndex.getText()
-                                                + ") with a type that doesn't 
use generics", methodParam);
-                                        } else if (gti<0 || 
gti>=genericsTypes.length) {
-                                            addStaticTypeError("Index of 
generic type @DelegatesTo(genericTypeIndex="+genericTypeIndex.getText()
-                                                    + ") 
"+(gti<0?"lower":"greater")+" than those of the selected type", methodParam);
+                                        if (genericsTypes == null) {
+                                            addStaticTypeError("Cannot use 
@DelegatesTo(genericTypeIndex=" + genericTypeIndex.getText()
+                                                    + ") with a type that 
doesn't use generics", methodParam);
+                                        } else if (gti < 0 || gti >= 
genericsTypes.length) {
+                                            addStaticTypeError("Index of 
generic type @DelegatesTo(genericTypeIndex=" + genericTypeIndex.getText()
+                                                    + ") " + (gti < 0 ? 
"lower" : "greater") + " than those of the selected type", methodParam);
                                         } else {
                                             ClassNode pType = 
GenericsUtils.parameterizeType(actualType, paramType);
                                             GenericsType[] pTypeGenerics = 
pType.getGenericsTypes();
-                                            if (pTypeGenerics!=null && 
pTypeGenerics.length>gti) {
+                                            if (pTypeGenerics != null && 
pTypeGenerics.length > gti) {
                                                 actualType = 
pTypeGenerics[gti].getType();
                                             } else {
-                                                addStaticTypeError("Unable to 
map actual type ["+actualType.toString(false)+"] onto 
"+paramType.toString(false), methodParam);
+                                                addStaticTypeError("Unable to 
map actual type [" + actualType.toString(false) + "] onto " + 
paramType.toString(false), methodParam);
                                             }
                                         }
                                     }
@@ -2924,7 +2928,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                             }
                         }
                     }
-                    if 
(expression.getNodeMetaData(StaticTypesMarker.DELEGATION_METADATA)==null) {
+                    if 
(expression.getNodeMetaData(StaticTypesMarker.DELEGATION_METADATA) == null) {
                         addError("Not enough arguments found for a 
@DelegatesTo method call. Please check that you either use an explicit class or 
@DelegatesTo.Target with a correct id", arguments);
                     }
                 }
@@ -2937,9 +2941,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     protected void addReceivers(final List<Receiver<String>> receivers,
-                              final Collection<Receiver<String>> owners,
-                              final boolean implicitThis) {
-        if (typeCheckingContext.delegationMetadata ==null || !implicitThis) {
+                                final Collection<Receiver<String>> owners,
+                                final boolean implicitThis) {
+        if (typeCheckingContext.delegationMetadata == null || !implicitThis) {
             receivers.addAll(owners);
             return;
         }
@@ -3067,7 +3071,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                             typeCheckClosureCall(callArguments, args, 
parameters);
                         }
                         ClassNode type = getType(((ASTNode) variable));
-                        if (type!=null && type.equals(CLOSURE_TYPE)) {
+                        if (type != null && type.equals(CLOSURE_TYPE)) {
                             GenericsType[] genericsTypes = 
type.getGenericsTypes();
                             type = OBJECT_TYPE;
                             if (genericsTypes != null) {
@@ -3170,7 +3174,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     if (areCategoryMethodCalls(mn, name, args)) {
                         addCategoryMethodCallError(call);
                     }
-                    mn = disambiguateMethods(mn, 
chosenReceiver!=null?chosenReceiver.getType():null, args, call);
+                    mn = disambiguateMethods(mn, chosenReceiver != null ? 
chosenReceiver.getType() : null, args, call);
 
 
                     if (mn.size() == 1) {
@@ -3181,7 +3185,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                             ClassNode owner = 
directMethodCallCandidate.getDeclaringClass();
                             addStaticTypeError("Non static method " + 
owner.getName() + "#" + directMethodCallCandidate.getName() + " cannot be 
called from static context", call);
                         }
-                        if (chosenReceiver==null) {
+                        if (chosenReceiver == null) {
                             chosenReceiver = 
Receiver.make(directMethodCallCandidate.getDeclaringClass());
                         }
 
@@ -3197,15 +3201,15 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                             returnType = irtg != null && 
implementsInterfaceOrIsSubclassOf(irtg, returnType) ? irtg : returnType;
                             callArgsVisited = true;
                         }
-                        if (directMethodCallCandidate==GET_DELEGATE && 
typeCheckingContext.getEnclosingClosure()!=null) {
+                        if (directMethodCallCandidate == GET_DELEGATE && 
typeCheckingContext.getEnclosingClosure() != null) {
                             DelegationMetadata md = 
getDelegationMetadata(typeCheckingContext.getEnclosingClosure().getClosureExpression());
                             returnType = 
typeCheckingContext.getEnclosingClassNode();
-                            if (md!=null) {
+                            if (md != null) {
                                 returnType = md.getType();
                             }
                         }
                         if 
(typeCheckMethodsWithGenericsOrFail(chosenReceiver.getType(), args, mn.get(0), 
call)) {
-                            returnType = 
adjustWithTraits(directMethodCallCandidate,chosenReceiver.getType(), args, 
returnType);
+                            returnType = 
adjustWithTraits(directMethodCallCandidate, chosenReceiver.getType(), args, 
returnType);
                             storeType(call, returnType);
                             storeTargetMethod(call, directMethodCallCandidate);
                             String data = chosenReceiver.getData();
@@ -3246,19 +3250,19 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 MethodNode mn = (MethodNode) 
call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
                 visitMethodCallArguments(receiver, argumentList, true, mn);
                 // GROOVY-6219
-                if (mn!=null) {
+                if (mn != null) {
                     List<Expression> argExpressions = 
argumentList.getExpressions();
                     Parameter[] parameters = mn.getParameters();
-                    for (int i = 0; i < argExpressions.size() && i< 
parameters.length; i++) {
-                          Expression arg = argExpressions.get(i);
-                          ClassNode pType = parameters[i].getType();
-                          ClassNode aType = getType(arg);
-                          if (CLOSURE_TYPE.equals(pType) && 
CLOSURE_TYPE.equals(aType)) {
-                              if (!isAssignableTo(aType, pType)) {
-                                  addNoMatchingMethodError(receiver, name, 
getArgumentTypes(argumentList), call);
-                                  
call.removeNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
-                              }
-                          }
+                    for (int i = 0; i < argExpressions.size() && i < 
parameters.length; i++) {
+                        Expression arg = argExpressions.get(i);
+                        ClassNode pType = parameters[i].getType();
+                        ClassNode aType = getType(arg);
+                        if (CLOSURE_TYPE.equals(pType) && 
CLOSURE_TYPE.equals(aType)) {
+                            if (!isAssignableTo(aType, pType)) {
+                                addNoMatchingMethodError(receiver, name, 
getArgumentTypes(argumentList), call);
+                                
call.removeNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
+                            }
+                        }
                     }
                 }
             }
@@ -3274,9 +3278,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * is created representing the list of trait interfaces.
      *
      * @param directMethodCallCandidate a method selected by the type checker
-     * @param receiver the receiver of the method call
-     * @param args the arguments of the method call
-     * @param returnType the original return type, as inferred by the type 
checker
+     * @param receiver                  the receiver of the method call
+     * @param args                      the arguments of the method call
+     * @param returnType                the original return type, as inferred 
by the type checker
      * @return fixed return type if the selected method is {@link 
org.codehaus.groovy.runtime.DefaultGroovyMethods#withTraits(Object, Class[]) 
withTraits}
      */
     private static ClassNode adjustWithTraits(final MethodNode 
directMethodCallCandidate, final ClassNode receiver, final ClassNode[] args, 
final ClassNode returnType) {
@@ -3292,7 +3296,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                         nodes.add(arg);
                     }
                 }
-                return new 
LowestUpperBoundClassNode(returnType.getName()+"Composed", OBJECT_TYPE, 
nodes.toArray(ClassNode.EMPTY_ARRAY));
+                return new LowestUpperBoundClassNode(returnType.getName() + 
"Composed", OBJECT_TYPE, nodes.toArray(ClassNode.EMPTY_ARRAY));
             }
         }
         return returnType;
@@ -3300,20 +3304,21 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     /**
      * add various getAt and setAt methods for primitive arrays
+     *
      * @param receiver the receiver class
-     * @param name  the name of the method
-     * @param args the argument classes
+     * @param name     the name of the method
+     * @param args     the argument classes
      */
     private static void addArrayMethods(List<MethodNode> methods, ClassNode 
receiver, String name, ClassNode[] args) {
-        if (args.length!=1) return;
+        if (args.length != 1) return;
         if (!receiver.isArray()) return;
         if (!isIntCategory(getUnwrapper(args[0]))) return;
         if ("getAt".equals(name)) {
-            MethodNode node = new MethodNode(name, Opcodes.ACC_PUBLIC, 
receiver.getComponentType(), new Parameter[]{new Parameter(args[0],"arg")}, 
null, null);
+            MethodNode node = new MethodNode(name, Opcodes.ACC_PUBLIC, 
receiver.getComponentType(), new Parameter[]{new Parameter(args[0], "arg")}, 
null, null);
             node.setDeclaringClass(receiver.redirect());
             methods.add(node);
         } else if ("setAt".equals(name)) {
-            MethodNode node = new MethodNode(name, Opcodes.ACC_PUBLIC, 
VOID_TYPE, new Parameter[]{new Parameter(args[0],"arg")}, null, null);
+            MethodNode node = new MethodNode(name, Opcodes.ACC_PUBLIC, 
VOID_TYPE, new Parameter[]{new Parameter(args[0], "arg")}, null, null);
             node.setDeclaringClass(receiver.redirect());
             methods.add(node);
         }
@@ -3334,7 +3339,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
         visitClosureExpression(closure);
 
-        if (getInferredReturnType(closure) != null)  {
+        if (getInferredReturnType(closure) != null) {
             return getInferredReturnType(closure);
         }
 
@@ -3343,6 +3348,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     /**
      * Given an object expression (a receiver expression), generate the list 
of potential receiver types.
+     *
      * @param objectExpression the receiver expression
      * @return the list of types the receiver may be
      */
@@ -3411,7 +3417,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     protected boolean isClosureCall(final String name, final Expression 
objectExpression, final Expression arguments) {
-        if (objectExpression instanceof ClosureExpression && 
(CALL.equals(name)||"doCall".equals(name))) return true;
+        if (objectExpression instanceof ClosureExpression && 
(CALL.equals(name) || "doCall".equals(name))) return true;
         if (objectExpression == VariableExpression.THIS_EXPRESSION) {
             FieldNode fieldNode = 
typeCheckingContext.getEnclosingClassNode().getDeclaredField(name);
             if (fieldNode != null) {
@@ -3473,7 +3479,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             instanceOfExpression = findNotInstanceOfReturnExpression(ifElse);
         }
         if (instanceOfExpression != null) {
-            if(typeCheckingContext.enclosingBlocks.size()>0) {
+            if (typeCheckingContext.enclosingBlocks.size() > 0) {
                 visitInstanceofNot(instanceOfExpression);
             }
         }
@@ -3520,10 +3526,10 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * Check IfStatement matched pattern :
      * Object var1;
      * if (!(var1 instanceOf Runnable)) {
-     *   return
+     * return
      * }
      * // Here var1 instance of Runnable
-     *
+     * <p>
      * Return expression , which contains instanceOf (without not)
      * Return null, if not found
      */
@@ -3556,10 +3562,10 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * Check IfStatement matched pattern :
      * Object var1;
      * if (var1 !instanceOf Runnable) {
-     *   return
+     * return
      * }
      * // Here var1 instance of Runnable
-     *
+     * <p>
      * Return expression , which contains instanceOf (without not)
      * Return null, if not found
      */
@@ -3633,7 +3639,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 // GROOVY-6099: First element of the list may be null, if no 
assignment was made before the branch
                 List<ClassNode> nonNullValues = new 
ArrayList<ClassNode>(allValues.size());
                 for (ClassNode value : allValues) {
-                    if (value!=null) nonNullValues.add(value);
+                    if (value != null) nonNullValues.add(value);
                 }
                 ClassNode cn = lowestUpperBound(nonNullValues);
                 storeType(key, cn);
@@ -3666,7 +3672,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     private boolean isDelegateOrOwnerInClosure(Expression exp) {
-        return typeCheckingContext.getEnclosingClosure()!=null &&
+        return typeCheckingContext.getEnclosingClosure() != null &&
                 exp instanceof VariableExpression &&
                 (("delegate".equals(((VariableExpression) exp).getName())) || 
("owner".equals(((VariableExpression) exp).getName())));
     }
@@ -3690,9 +3696,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             // char c = (char) ...
         } else if (sourceIsNull && isPrimitiveType(targetType) && 
!boolean_TYPE.equals(targetType)) {
             return false;
-        } else if ((expressionType.getModifiers()& Opcodes.ACC_FINAL)==0 && 
targetType.isInterface()) {
+        } else if ((expressionType.getModifiers() & Opcodes.ACC_FINAL) == 0 && 
targetType.isInterface()) {
             return true;
-        } else if ((targetType.getModifiers()& Opcodes.ACC_FINAL)==0 && 
expressionType.isInterface()) {
+        } else if ((targetType.getModifiers() & Opcodes.ACC_FINAL) == 0 && 
expressionType.isInterface()) {
             return true;
         } else if (!isAssignableTo(targetType, expressionType) && 
!implementsInterfaceOrIsSubclassOf(expressionType, targetType)) {
             return false;
@@ -3728,7 +3734,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         typeOfTrue = checkForTargetType(trueExpression, typeOfTrue);
         if (isNullConstant(trueExpression) || isNullConstant(falseExpression)) 
{
             BinaryExpression enclosingBinaryExpression = 
typeCheckingContext.getEnclosingBinaryExpression();
-            if (enclosingBinaryExpression != null && 
enclosingBinaryExpression.getRightExpression()==expression) {
+            if (enclosingBinaryExpression != null && 
enclosingBinaryExpression.getRightExpression() == expression) {
                 resultType = 
getType(enclosingBinaryExpression.getLeftExpression());
             } else if (isNullConstant(trueExpression) && 
isNullConstant(falseExpression)) {
                 resultType = OBJECT_TYPE;
@@ -3777,7 +3783,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 
     private static boolean isEmptyCollection(Expression expr) {
         return (expr instanceof ListExpression && ((ListExpression) 
expr).getExpressions().size() == 0) ||
-        (expr instanceof MapExpression && ((MapExpression) 
expr).getMapEntryExpressions().size() == 0);
+                (expr instanceof MapExpression && ((MapExpression) 
expr).getMapEntryExpressions().size() == 0);
     }
 
     private static boolean hasInferredReturnType(Expression expression) {
@@ -3828,9 +3834,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             // DECLARATION_INFERRED_TYPE is the type which should be used for 
the initial type declaration
             ClassNode oldDIT = (ClassNode) 
exp.getNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE);
             if (oldDIT != null) {
-                
exp.putNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE, 
cn==null?oldDIT : lowestUpperBound(oldDIT, cn));
+                
exp.putNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE, cn == null ? 
oldDIT : lowestUpperBound(oldDIT, cn));
             } else {
-                
exp.putNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE, cn==null?null 
: lowestUpperBound(oldValue, cn));
+                
exp.putNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE, cn == null ? 
null : lowestUpperBound(oldValue, cn));
             }
         }
         if (exp instanceof VariableExpression) {
@@ -3842,7 +3848,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             if (accessedVariable instanceof Parameter) {
                 ((Parameter) 
accessedVariable).putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, cn);
             }
-            if (var.isClosureSharedVariable() && cn!=null) {
+            if (var.isClosureSharedVariable() && cn != null) {
                 List<ClassNode> assignedTypes = 
typeCheckingContext.closureSharedVariablesAssignmentTypes.get(var);
                 if (assignedTypes == null) {
                     assignedTypes = new LinkedList<ClassNode>();
@@ -3868,7 +3874,8 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         Expression leftExpression = expr.getLeftExpression();
         Expression rightExpression = expr.getRightExpression();
         if (op == ASSIGN || op == ASSIGNMENT_OPERATOR || op == ELVIS_EQUAL) {
-            if (leftRedirect.isArray() && 
implementsInterfaceOrIsSubclassOf(rightRedirect, Collection_TYPE)) return 
leftRedirect;
+            if (leftRedirect.isArray() && 
implementsInterfaceOrIsSubclassOf(rightRedirect, Collection_TYPE))
+                return leftRedirect;
             if (leftRedirect.implementsInterface(Collection_TYPE) && 
rightRedirect.implementsInterface(Collection_TYPE)) {
                 // because of type inference, we must perform an additional 
check if the right expression
                 // is an empty list expression ([]). In that case and only in 
that case, the inferred type
@@ -3884,7 +3891,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 return right;
             }
             if (rightRedirect.isDerivedFrom(CLOSURE_TYPE) && 
isSAMType(leftRedirect) && rightExpression instanceof ClosureExpression) {
-                return inferSAMTypeGenericsInAssignment(left, 
findSAM(left),right,(ClosureExpression) rightExpression);
+                return inferSAMTypeGenericsInAssignment(left, findSAM(left), 
right, (ClosureExpression) rightExpression);
             }
 
             if (leftExpression instanceof VariableExpression) {
@@ -3893,7 +3900,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     return getWrapper(right);
                 }
 
-                if (isPrimitiveType(initialType) && 
rightRedirect.isDerivedFrom(Number_TYPE))  {
+                if (isPrimitiveType(initialType) && 
rightRedirect.isDerivedFrom(Number_TYPE)) {
                     return getUnwrapper(right);
                 }
 
@@ -3916,10 +3923,10 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             BinaryExpression newExpr = binX(expr.getLeftExpression(), 
expr.getOperation(), rightExpression);
             newExpr.setSourcePosition(expr);
             MethodNode method = findMethodOrFail(newExpr, 
left.getPlainNodeReference(), "getAt", right.getPlainNodeReference());
-            if (method!=null && implementsInterfaceOrIsSubclassOf(right, 
RANGE_TYPE)) {
+            if (method != null && implementsInterfaceOrIsSubclassOf(right, 
RANGE_TYPE)) {
                 return inferReturnTypeGenerics(left, method, rightExpression);
             }
-            return method!=null?inferComponentType(left, right):null;
+            return method != null ? inferComponentType(left, right) : null;
         }
         if (op == FIND_REGEX) {
             // this case always succeeds the result is a Matcher
@@ -3962,9 +3969,12 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             } else if (isPowerOperator(op)) {
                 return Number_TYPE;
             } else if (isBitOperator(op) || op == INTDIV || op == 
INTDIV_EQUAL) {
-                if (isIntCategory(getUnwrapper(leftRedirect)) && 
isIntCategory(getUnwrapper(rightRedirect))) return int_TYPE;
-                if (isLongCategory(getUnwrapper(leftRedirect)) && 
isLongCategory(getUnwrapper(rightRedirect))) return long_TYPE;
-                if (isBigIntCategory(getUnwrapper(leftRedirect)) && 
isBigIntCategory(getUnwrapper(rightRedirect))) return BigInteger_TYPE;
+                if (isIntCategory(getUnwrapper(leftRedirect)) && 
isIntCategory(getUnwrapper(rightRedirect)))
+                    return int_TYPE;
+                if (isLongCategory(getUnwrapper(leftRedirect)) && 
isLongCategory(getUnwrapper(rightRedirect)))
+                    return long_TYPE;
+                if (isBigIntCategory(getUnwrapper(leftRedirect)) && 
isBigIntCategory(getUnwrapper(rightRedirect)))
+                    return BigInteger_TYPE;
             } else if (isCompareToBoolean(op) || op == COMPARE_EQUAL || op == 
COMPARE_NOT_EQUAL) {
                 return boolean_TYPE;
             }
@@ -4007,21 +4017,21 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         // we cannot infer anything, thus we simply return the provided 
samUsage
         GenericsType[] samGt = samUsage.getGenericsTypes();
         GenericsType[] closureGt = closureType.getGenericsTypes();
-        if (samGt==null || closureGt==null) return samUsage;
+        if (samGt == null || closureGt == null) return samUsage;
 
         // extract the generics from the return type
-        Map<String,GenericsType> connections = new 
HashMap<String,GenericsType>();
-        extractGenericsConnections(connections, 
getInferredReturnType(closureExpression),sam.getReturnType());
+        Map<String, GenericsType> connections = new HashMap<String, 
GenericsType>();
+        extractGenericsConnections(connections, 
getInferredReturnType(closureExpression), sam.getReturnType());
 
         // next we get the block parameter types and set the generics
         // information just like before
         // TODO: add vargs handling
         Parameter[] closureParams = closureExpression.getParameters();
         Parameter[] methodParams = sam.getParameters();
-        for (int i=0; i<closureParams.length; i++) {
+        for (int i = 0; i < closureParams.length; i++) {
             ClassNode fromClosure = closureParams[i].getType();
             ClassNode fromMethod = methodParams[i].getType();
-            extractGenericsConnections(connections,fromClosure,fromMethod);
+            extractGenericsConnections(connections, fromClosure, fromMethod);
         }
         ClassNode result = applyGenericsContext(connections, 
samUsage.redirect());
         return result;
@@ -4096,14 +4106,14 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
     }
 
     private List<MethodNode> disambiguateMethods(List<MethodNode> methods, 
ClassNode receiver, ClassNode[] argTypes, final Expression call) {
-        if (methods.size()>1 && receiver!=null && argTypes!=null) {
+        if (methods.size() > 1 && receiver != null && argTypes != null) {
             List<MethodNode> filteredWithGenerics = new 
LinkedList<MethodNode>();
             for (MethodNode methodNode : methods) {
                 if (typeCheckMethodsWithGenerics(receiver, argTypes, 
methodNode)) {
                     filteredWithGenerics.add(methodNode);
                 }
             }
-            if (filteredWithGenerics.size()==1) {
+            if (filteredWithGenerics.size() == 1) {
                 return filteredWithGenerics;
             }
             methods = extension.handleAmbiguousMethods(methods, call);
@@ -4138,7 +4148,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
             sb.append(node.getDeclaringClass().toString(false));
             sb.append("#");
             sb.append(toMethodParametersString(node.getName(), 
extractTypesFromParameters(node.getParameters())));
-            if (i<nodesSize-1) sb.append(", ");
+            if (i < nodesSize - 1) sb.append(", ");
         }
         sb.append("]");
         return sb.toString();
@@ -4163,8 +4173,9 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
      * are defined on the specified receiver, but it will also add "non 
existing" methods
      * that will be generated afterwards by the compiler, for example if a 
method is using
      * default values and that the specified class node isn't compiled yet.
+     *
      * @param receiver the receiver where to find methods
-     * @param name the name of the methods to return
+     * @param name     the name of the methods to return
      * @return the methods that are defined on the receiver completed with 
stubs for future methods
      */
     protected List<MethodNode> findMethodsWithGenerated(ClassNode receiver, 
String name) {
@@ -4206,7 +4217,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                 }
                 MethodNode stubbed;
                 if ("<init>".equals(method.getName())) {
-                    stubbed= new ConstructorNode(
+                    stubbed = new ConstructorNode(
                             method.getModifiers(),
                             newParams,
                             method.getExceptions(),
@@ -4214,7 +4225,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                     );
 
                 } else {
-                    stubbed= new MethodNode(
+                    stubbed = new MethodNode(
                             method.getName(),
                             method.getModifiers(),
                             method.getReturnType(),
@@ -4236,7 +4247,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
         if (isPrimitiveType(receiver)) re

<TRUNCATED>

Reply via email to