You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/10/30 15:55:28 UTC
[groovy] 04/17: Minor refactor
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit df1598b2675ee21fd4e42af578ed41d9589534bf
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Oct 29 10:03:38 2019 +0800
Minor refactor
(cherry picked from commit 13128c1246c05b6833b9a4f558248ce6128e800c)
---
.../groovy/transform/stc/StaticTypeCheckingVisitor.java | 15 +++++++++------
src/test/groovy/bugs/Groovy9288.groovy | 2 +-
src/test/groovy/bugs/Groovy9293.groovy | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 5161529..bbf0cda 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -222,7 +222,6 @@ import static org.codehaus.groovy.syntax.Types.MINUS_MINUS;
import static org.codehaus.groovy.syntax.Types.MOD;
import static org.codehaus.groovy.syntax.Types.MOD_EQUAL;
import static org.codehaus.groovy.syntax.Types.PLUS_PLUS;
-import static org.codehaus.groovy.transform.sc.StaticCompilationMetadataKeys.RECEIVER_OF_DYNAMIC_PROPERTY;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.ArrayList_TYPE;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Collection_TYPE;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Matcher_TYPE;
@@ -1509,9 +1508,6 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
return existsProperty(pexp, checkForReadOnly, null);
}
- private static final Set<String> CLOSURE_IMPLICIT_VARIABLE_SET =
- Collections.unmodifiableSet(new HashSet<>(Arrays.asList("it", "this", "thisObject", "owner", "delegate")));
-
/**
* Checks whether a property exists on the receiver, or on any of the possible receiver classes (found in the
* temporary type information table)
@@ -1597,8 +1593,15 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
if (null != field) {
int fieldModifiers = field.getModifiers();
if (Modifier.isProtected(fieldModifiers) || isPackagePrivate(fieldModifiers)) {
- if (null != typeCheckingContext.getEnclosingClosure() && CLOSURE_IMPLICIT_VARIABLE_SET.contains(objectExpression.getText())) {
- objectExpression.putNodeMetaData(RECEIVER_OF_DYNAMIC_PROPERTY, OBJECT_TYPE);
+ TypeCheckingContext.EnclosingClosure enclosingClosure = typeCheckingContext.getEnclosingClosure();
+ if (null != enclosingClosure) {
+ switch (objectExpression.getText()) {
+ case "it":
+ case "owner":
+ case "delegate":
+ case "thisObject":
+ pexp.putNodeMetaData(DYNAMIC_RESOLUTION, Boolean.TRUE);
+ }
}
}
}
diff --git a/src/test/groovy/bugs/Groovy9288.groovy b/src/test/groovy/bugs/Groovy9288.groovy
index 87f2ac8..e898b93 100644
--- a/src/test/groovy/bugs/Groovy9288.groovy
+++ b/src/test/groovy/bugs/Groovy9288.groovy
@@ -18,7 +18,7 @@
*/
package groovy.bugs
-import groovy.test.NotYetImplemented
+
import org.junit.Test
final class Groovy9288 {
diff --git a/src/test/groovy/bugs/Groovy9293.groovy b/src/test/groovy/bugs/Groovy9293.groovy
index c50276a..282bf50 100644
--- a/src/test/groovy/bugs/Groovy9293.groovy
+++ b/src/test/groovy/bugs/Groovy9293.groovy
@@ -18,7 +18,7 @@
*/
package groovy.bugs
-import groovy.test.NotYetImplemented
+
import org.junit.Test
import static groovy.test.GroovyAssert.shouldFail