groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [2/2] groovy git commit: GROOVY-8246: AIOOBE in StaticTypeCheckingVisitor with SAM (closes #601)
Date Thu, 14 Sep 2017 10:23:35 GMT
GROOVY-8246: AIOOBE in StaticTypeCheckingVisitor with SAM (closes #601)


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 423d47d35cfd255b6e5dbe5ad2aac5498a64e5ed
Parents: 9b6b4ab
Author: paulk <paulk@asert.com.au>
Authored: Thu Sep 14 19:41:00 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Thu Sep 14 20:23:23 2017 +1000

----------------------------------------------------------------------
 .../stc/StaticTypeCheckingVisitor.java          |  2 +-
 .../groovy/transform/stc/Groovy8246Bug.groovy   | 36 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/423d47d3/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 d875d31..06ac1eb 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -3999,7 +3999,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
                 ClassNode[] closureParamTypes = (ClassNode[])(enclosingClosure!=null?enclosingClosure.getClosureExpression().getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS):null);
                 if (type==null && enclosingClosure !=null && "it".equals(variable.getName())
&& closureParamTypes!=null) {
                     final Parameter[] parameters = enclosingClosure.getClosureExpression().getParameters();
-                    if (parameters.length==0 && getTemporaryTypesForExpression(vexp)==null)
{
+                    if (parameters.length==0 && getTemporaryTypesForExpression(vexp)==null
&& closureParamTypes.length!=0) {
                         type = closureParamTypes[0];
                     }
                 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/423d47d3/src/test/groovy/transform/stc/Groovy8246Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/Groovy8246Bug.groovy b/src/test/groovy/transform/stc/Groovy8246Bug.groovy
new file mode 100644
index 0000000..e634a76
--- /dev/null
+++ b/src/test/groovy/transform/stc/Groovy8246Bug.groovy
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package groovy.transform.stc
+
+class Groovy8246Bug extends StaticTypeCheckingTestCase {
+    void testClosureWithImplicitParamNoInferrableArguments() {
+        assertScript '''
+            def runnable(Runnable r) {
+                r.run()
+            }
+            def foo() {
+                runnable {
+                    println it
+                }
+            }
+            foo()
+        '''
+    }
+}


Mime
View raw message