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-8362: don't resolve class via class with package name
Date Thu, 04 Jan 2018 04:02:55 GMT
GROOVY-8362: don't resolve class via class with package name


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

Branch: refs/heads/GROOVY_2_6_X
Commit: c43ca58e8f5bfe76c05ef0907b0365ac7f934f2a
Parents: 3547b50
Author: Daniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Authored: Fri Dec 22 19:01:10 2017 +0300
Committer: paulk <paulk@asert.com.au>
Committed: Thu Jan 4 14:02:40 2018 +1000

----------------------------------------------------------------------
 .../codehaus/groovy/control/ResolveVisitor.java    |  2 +-
 .../groovy/lang/InnerClassResolvingTest.groovy     | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c43ca58e/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
index 895b5db..42d9f6f 100644
--- a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
@@ -360,7 +360,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
     }
 
     private boolean resolveNestedClass(ClassNode type) {
-        if (type instanceof ConstructedNestedClass) return false;
+        if (type instanceof ConstructedNestedClass || type instanceof ConstructedClassWithPackage)
return false;
         // we have for example a class name A, are in class X
         // and there is a nested class A$X. we want to be able 
         // to access that class directly, so A becomes a valid

http://git-wip-us.apache.org/repos/asf/groovy/blob/c43ca58e/src/test/groovy/lang/InnerClassResolvingTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/lang/InnerClassResolvingTest.groovy b/src/test/groovy/lang/InnerClassResolvingTest.groovy
index 4060ecc..27b0fcb 100644
--- a/src/test/groovy/lang/InnerClassResolvingTest.groovy
+++ b/src/test/groovy/lang/InnerClassResolvingTest.groovy
@@ -42,4 +42,21 @@ class InnerClassResolvingTest extends GroovyTestCase {
         new GroovyShell().evaluate(script)
     }
 
+    void 'test dont resolve class via inner class with package name'() {
+        shouldFail '''\
+package bugs
+
+class Current {
+
+  static class bugs {
+    static class Target {}
+  }
+
+  static usage() {
+    new Target()
+  }
+}
+assert Current.usage()
+'''
+    }
 }


Mime
View raw message