groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject groovy git commit: GROOVY-8240: Compilation error in @CompileStatic (closes #570)
Date Wed, 05 Jul 2017 00:32:45 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 44b89dab6 -> 8f6b7cdb7


GROOVY-8240: Compilation error in @CompileStatic (closes #570)


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

Branch: refs/heads/master
Commit: 8f6b7cdb7239e7e17b3fd42807558c0c85b50e3d
Parents: 44b89da
Author: alexey.afanasiev <Alexey.Afanasiev@jetbrains.com>
Authored: Thu Jun 29 16:27:38 2017 +0300
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Tue Jul 4 15:24:05 2017 -0700

----------------------------------------------------------------------
 .../stc/StaticTypeCheckingVisitor.java          |  2 +-
 .../classgen/asm/sc/bugs/Groovy8240Bug.groovy   | 72 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8f6b7cdb/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 b7f00b6..7e38ac4 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -3814,7 +3814,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
                     );
                     stubbed.setGenericsTypes(method.getGenericsTypes());
                 }
-                stubbed.setDeclaringClass(receiver);
+                stubbed.setDeclaringClass(method.getDeclaringClass());
                 result.add(stubbed);
             }
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f6b7cdb/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8240Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8240Bug.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8240Bug.groovy
new file mode 100644
index 0000000..2dbb0e3
--- /dev/null
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8240Bug.groovy
@@ -0,0 +1,72 @@
+/*
+ *  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 org.codehaus.groovy.classgen.asm.sc.bugs
+
+import groovy.transform.stc.StaticTypeCheckingTestCase
+import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
+
+class Groovy8240Bug extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport
{
+    void testDefaultArguments() {
+        assertScript '''
+            class Bar {
+                void vararg(boolean flag = true, Class<?>... classes) {}
+            }
+            
+            class Foo extends Bar{
+              def test() {
+                  vararg(false, Foo)
+              }
+            }
+            
+            new Foo().test()
+        '''
+    }
+
+    void testDefaultArgumentsWith2Vararg() {
+        assertScript '''
+            class Bar {
+                void vararg(boolean flag = true, Class<?>... classes) {}
+            }
+            
+            class Foo extends Bar{
+              def test() {
+                  vararg(false, Foo, Bar)
+              }
+            }
+            
+            new Foo().test()
+        '''
+    }
+
+    void testDefaultArgumentsWithoutVararg() {
+        assertScript '''
+            class Bar {
+                void vararg(boolean flag = true, Class<?>... classes) {}
+            }
+            
+            class Foo extends Bar{
+              def test() {
+                  vararg(false)
+              }
+            }
+            
+            new Foo().test()
+        '''
+    }
+}


Mime
View raw message