groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: GROOVY-7929: @SelfType compilation fail
Date Thu, 25 Jan 2018 03:25:39 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 58402af07 -> 64f89a60b


GROOVY-7929: @SelfType compilation fail


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

Branch: refs/heads/GROOVY_2_5_X
Commit: 64f89a60b23e9a6b7bda057b3ad14deac88125f7
Parents: 58402af
Author: paulk <paulk@asert.com.au>
Authored: Thu Jan 25 13:25:13 2018 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Thu Jan 25 13:25:32 2018 +1000

----------------------------------------------------------------------
 .../transform/stc/TraitTypeCheckingExtension.java |  5 ++---
 src/test/groovy/transform/stc/BugsSTCTest.groovy  | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/64f89a60/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
b/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
index 1ba75f4..9bc93b5 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
@@ -38,9 +38,8 @@ import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isClas
 
 /**
  * A type checking extension that will take care of handling errors which are specific to
traits. In particular, it will
- * hanldle the "super" method calls within a trait.
+ * handle the "super" method calls within a trait.
  *
- * @author C├ędric Champeau
  * @since 2.3.0
  */
 public class TraitTypeCheckingExtension extends AbstractTypeCheckingExtension {
@@ -78,7 +77,7 @@ public class TraitTypeCheckingExtension extends AbstractTypeCheckingExtension
{
                 } else if (isThisTraitReceiver(var)) {
                     type = receiver;
                 }
-                if (type != null && Traits.isTrait(type)) {
+                if (type != null && Traits.isTrait(type) && !(type instanceof
UnionTypeClassNode)) {
                     ClassNode helper = Traits.findHelper(type);
                     Parameter[] params = new Parameter[argumentTypes.length + 1];
                     params[0] = new Parameter(ClassHelper.CLASS_Type.getPlainNodeReference(),
"staticSelf");

http://git-wip-us.apache.org/repos/asf/groovy/blob/64f89a60/src/test/groovy/transform/stc/BugsSTCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/BugsSTCTest.groovy b/src/test/groovy/transform/stc/BugsSTCTest.groovy
index 3a3df35..ef570c6 100644
--- a/src/test/groovy/transform/stc/BugsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/BugsSTCTest.groovy
@@ -77,13 +77,29 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
             def bar() { foo { it - 2 } }
         ''', 'Cannot find matching method java.lang.Object#minus(int)'
     }
-    void testShouldNotAllowMinusBynUntypedVariable() {
+    void testShouldNotAllowMinusByUntypedVariable() {
         shouldFailWithMessages '''
             def foo(Closure cls) {}
             def bar() { foo { 2 - it } }
         ''', 'Cannot find matching method int#minus(java.lang.Object)'
     }
 
+    // GROOVY-7929
+    void testShouldDetectInvalidMethodUseWithinTraitWithCompileStaticAndSelfType() {
+        shouldFailWithMessages '''
+            class C1 {
+                def c1() { }
+            }
+            @groovy.transform.CompileStatic
+            @groovy.transform.SelfType(C1)
+            trait TT {
+                def foo() {
+                    c2()
+                }
+            }
+        ''', 'Cannot find matching method <UnionType:C1+TT>#c2'
+    }
+
     void testGroovy5444() {
         assertScript '''
                 def curr = { System.currentTimeMillis() }


Mime
View raw message