[1/3] groovy git commit: Fix a generic types comparison

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[1/3] groovy git commit: Fix a generic types comparison

pascalschumacher
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X 1864bb962 -> 71b68dd98


Fix a generic types comparison


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 197472cb626bdada5e079c7f0cd145b85502f034
Parents: 1864bb9
Author: Frank Pavageau <[hidden email]>
Authored: Wed Dec 16 13:45:41 2015 +0100
Committer: pascalschumacher <[hidden email]>
Committed: Sun Dec 20 12:40:47 2015 +0100

----------------------------------------------------------------------
 .../codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/197472cb/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index eb6bac9..69359e9 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1576,7 +1576,7 @@ public abstract class StaticTypeCheckingSupport {
         if (orig.isGenericsPlaceHolder()!=copy.isGenericsPlaceHolder()) return false;
         if (!orig.equals(copy)) return false;
         GenericsType[] gt1 = orig.getGenericsTypes();
-        GenericsType[] gt2 = orig.getGenericsTypes();
+        GenericsType[] gt2 = copy.getGenericsTypes();
         if ((gt1==null || gt2==null) && gt1!=gt2) return false;
         if (gt1==gt2) return true;
         if (gt1.length!=gt2.length) return false;

Reply | Threaded
Open this post in threaded view
|

[2/3] groovy git commit: Simplify some expressions

pascalschumacher
Simplify some expressions


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 19596919af5036ed10cf6fd75f401c1a3cbfe768
Parents: 197472c
Author: Frank Pavageau <[hidden email]>
Authored: Wed Dec 16 13:47:26 2015 +0100
Committer: pascalschumacher <[hidden email]>
Committed: Sun Dec 20 12:40:48 2015 +0100

----------------------------------------------------------------------
 .../stc/StaticTypeCheckingSupport.java          |  7 +++----
 .../stc/StaticTypeCheckingVisitor.java          | 22 ++++++++++----------
 2 files changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/19596919/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index 69359e9..cfc2fb7 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1577,7 +1577,7 @@ public abstract class StaticTypeCheckingSupport {
         if (!orig.equals(copy)) return false;
         GenericsType[] gt1 = orig.getGenericsTypes();
         GenericsType[] gt2 = copy.getGenericsTypes();
-        if ((gt1==null || gt2==null) && gt1!=gt2) return false;
+        if ((gt1==null) ^ (gt2==null)) return false;
         if (gt1==gt2) return true;
         if (gt1.length!=gt2.length) return false;
         for (int i=0; i<gt1.length; i++) {
@@ -1864,11 +1864,10 @@ public abstract class StaticTypeCheckingSupport {
     private static Map<String, GenericsType> mergeGenerics(Map<String, GenericsType> current, GenericsType[] newGenerics) {
         if (newGenerics == null || newGenerics.length == 0) return current;
         if (current==null) current = new HashMap<String, GenericsType>();
-        for (int i = 0; i < newGenerics.length; i++) {
-            GenericsType gt = newGenerics[i];
+        for (GenericsType gt : newGenerics) {
             if (!gt.isPlaceholder()) continue;
             String name = gt.getName();
-            if (!current.containsKey(name)) current.put(name, newGenerics[i]);
+            if (!current.containsKey(name)) current.put(name, gt);
         }
         return current;
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/19596919/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index a5bde88..1300e80 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -881,7 +881,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
     private boolean addedReadOnlyPropertyError(Expression expr) {
         // if expr is of READONLY_PROPERTY_RETURN type, then it means we are on a missing property
         if (expr.getNodeMetaData(StaticTypesMarker.READONLY_PROPERTY) == null) return false;
-        String name = null;
+        String name;
         if (expr instanceof VariableExpression) {
             name = ((VariableExpression) expr).getName();
         } else {
@@ -1410,7 +1410,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
     private <T> T allowStaticAccessToMember(T member, boolean staticOnly) {
         if (member == null) return null;
         if (!staticOnly) return member;
-        boolean isStatic = false;
+        boolean isStatic;
         if (member instanceof Variable) {
             Variable v = (Variable) member;
             isStatic = Modifier.isStatic(v.getModifiers());
@@ -1859,7 +1859,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         }
 
 
-        MethodNode node = null;
+        MethodNode node;
         if (args.length == 1
                 && implementsInterfaceOrIsSubclassOf(args[0], MAP_TYPE)
                 && findMethod(receiver, "<init>", ClassNode.EMPTY_ARRAY).size() == 1
@@ -2389,7 +2389,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
 
     private List<ClassNode[]> getSignaturesFromHint(final ClosureExpression expression, final MethodNode selectedMethod, final Expression hintClass, final Expression options) {
         // initialize hints
-        List<ClassNode[]> closureSignatures = null;
+        List<ClassNode[]> closureSignatures;
         try {
             ClassLoader transformLoader = getTransformLoader();
             @SuppressWarnings("unchecked")
@@ -2835,7 +2835,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                         storeType(call, data);
                     }
                 }
-                int nbOfArgs = 0;
+                int nbOfArgs;
                 if (callArguments instanceof ArgumentListExpression) {
                     ArgumentListExpression list = (ArgumentListExpression) callArguments;
                     nbOfArgs = list.getExpressions().size();
@@ -3715,14 +3715,14 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                 Parameter[] newParams = new Parameter[parameters.length - j];
                 int index = 0;
                 int k = 1;
-                for (int i = 0; i < parameters.length; i++) {
-                    if (k > counter - j && parameters[i] != null && parameters[i].hasInitialExpression()) {
+                for (Parameter parameter : parameters) {
+                    if (k > counter - j && parameter != null && parameter.hasInitialExpression()) {
                         k++;
-                    } else if (parameters[i] != null && parameters[i].hasInitialExpression()) {
-                        newParams[index++] = parameters[i];
+                    } else if (parameter != null && parameter.hasInitialExpression()) {
+                        newParams[index++] = parameter;
                         k++;
                     } else {
-                        newParams[index++] = parameters[i];
+                        newParams[index++] = parameter;
                     }
                 }
                 MethodNode stubbed;
@@ -4028,7 +4028,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
      */
     private ClassNode getGenericsResolvedTypeOfFieldOrProperty(AnnotatedNode an, ClassNode type) {
         if (!type.isUsingGenerics()) return type;
-        Map<String, GenericsType> connections = new HashMap();
+        Map<String, GenericsType> connections = new HashMap<String, GenericsType>();
         //TODO: inner classes mean a different this-type. This is ignored here!
         extractGenericsConnections(connections, typeCheckingContext.getEnclosingClassNode(), an.getDeclaringClass());
         type= applyGenericsContext(connections, type);

Reply | Threaded
Open this post in threaded view
|

[3/3] groovy git commit: Remove some unused statements (closes #214)

pascalschumacher
In reply to this post by pascalschumacher
Remove some unused statements (closes #214)


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 71b68dd98c3d18d3a1296f54eb16859609b05cb1
Parents: 1959691
Author: Frank Pavageau <[hidden email]>
Authored: Wed Dec 16 15:12:46 2015 +0100
Committer: pascalschumacher <[hidden email]>
Committed: Sun Dec 20 12:40:48 2015 +0100

----------------------------------------------------------------------
 .../codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java   | 2 --
 .../codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java   | 2 --
 2 files changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/71b68dd9/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index cfc2fb7..e560490 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1313,7 +1313,6 @@ public abstract class StaticTypeCheckingSupport {
             return typeCheckMethodsWithGenerics(receiver.getGenericsTypes()[0].getType(), arguments, candidateMethod);
         }
         // both candidate method and receiver have generic information so a check is possible
-        Parameter[] parameters = candidateMethod.getParameters();
         GenericsType[] genericsTypes = candidateMethod.getGenericsTypes();
         boolean methodUsesGenerics = (genericsTypes != null && genericsTypes.length > 0);
         boolean isExtensionMethod = candidateMethod instanceof ExtensionMethodNode;
@@ -1890,7 +1889,6 @@ public abstract class StaticTypeCheckingSupport {
     private static class ExtensionMethodCache {
 
         private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-        private List<ExtensionModule> modules = Collections.emptyList();
         private Map<String, List<MethodNode>> cachedMethods = null;
         private WeakReference<ClassLoader> origin = new WeakReference<ClassLoader>(null);
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/71b68dd9/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 1300e80..9a3f376 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -2161,7 +2161,6 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             return;
         }
 
-        final ClassNode rememberLastItType = typeCheckingContext.lastImplicitItType;
         Expression callArguments = call.getArguments();
 
         ArgumentListExpression argumentList = InvocationWriter.makeArgumentList(callArguments);
@@ -2772,7 +2771,6 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             }
         }
 
-        final ClassNode rememberLastItType = typeCheckingContext.lastImplicitItType;
         Expression callArguments = call.getArguments();
         ArgumentListExpression argumentList = InvocationWriter.makeArgumentList(callArguments);