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-8362: don't resolve class via class with package name
Date Thu, 04 Jan 2018 04:03:59 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X cf2fb40f1 -> e9c09dbb8


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/e9c09dbb
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e9c09dbb
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e9c09dbb

Branch: refs/heads/GROOVY_2_4_X
Commit: e9c09dbb852829ffaf67c63a2deb4b6a1b72fc4a
Parents: cf2fb40
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:03:46 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/e9c09dbb/src/main/org/codehaus/groovy/control/ResolveVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/ResolveVisitor.java b/src/main/org/codehaus/groovy/control/ResolveVisitor.java
index 15448be..300416b 100644
--- a/src/main/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/org/codehaus/groovy/control/ResolveVisitor.java
@@ -352,7 +352,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/e9c09dbb/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