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 2018/10/20 14:08:07 UTC
[1/2] groovy git commit: Fix the failing build
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_5_X cc59285cc -> 2d1ef39e2
Fix the failing build
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/183fd9e8
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/183fd9e8
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/183fd9e8
Branch: refs/heads/GROOVY_2_5_X
Commit: 183fd9e8cb54198e59a2d1e526e517a2b156043a
Parents: cc59285
Author: Daniel Sun <su...@apache.org>
Authored: Sat Oct 20 22:07:46 2018 +0800
Committer: Daniel Sun <su...@apache.org>
Committed: Sat Oct 20 22:07:46 2018 +0800
----------------------------------------------------------------------
src/main/groovy/groovy/lang/MetaClassImpl.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/183fd9e8/src/main/groovy/groovy/lang/MetaClassImpl.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/MetaClassImpl.java b/src/main/groovy/groovy/lang/MetaClassImpl.java
index 8f1ee53..0dc6506 100644
--- a/src/main/groovy/groovy/lang/MetaClassImpl.java
+++ b/src/main/groovy/groovy/lang/MetaClassImpl.java
@@ -3981,15 +3981,15 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
MetaClass delegateMetaClass = lookupObjectMetaClass(delegate);
method = delegateMetaClass.pickMethod(methodName, argClasses);
if (method != null)
- return new Tuple2<>(delegateMetaClass.invokeMethod(delegate, methodName, originalArguments), method);
+ return new Tuple2<Object,MetaMethod>(delegateMetaClass.invokeMethod(delegate, methodName, originalArguments), method);
}
if (method == null && owner != closure) {
MetaClass ownerMetaClass = lookupObjectMetaClass(owner);
method = ownerMetaClass.pickMethod(methodName, argClasses);
- if (method != null) return new Tuple2<>(ownerMetaClass.invokeMethod(owner, methodName, originalArguments), method);
+ if (method != null) return new Tuple2<Object,MetaMethod>(ownerMetaClass.invokeMethod(owner, methodName, originalArguments), method);
}
- return new Tuple2<>(InvokeMethodResult.NONE, method);
+ return new Tuple2<Object,MetaMethod>(InvokeMethodResult.NONE, method);
}
private enum InvokeMethodResult {
[2/2] groovy git commit: Minor refactoring: extract method
`resolveFromDefaultImports`
Posted by su...@apache.org.
Minor refactoring: extract method `resolveFromDefaultImports`
(cherry picked from commit 8545fed53b0964b567d7b7c00b00cb284bd51392)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/2d1ef39e
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/2d1ef39e
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/2d1ef39e
Branch: refs/heads/GROOVY_2_5_X
Commit: 2d1ef39e2f85cbfdfb4d2342da59700755815cb1
Parents: 183fd9e
Author: Daniel Sun <su...@apache.org>
Authored: Sat Oct 20 21:58:38 2018 +0800
Committer: Daniel Sun <su...@apache.org>
Committed: Sat Oct 20 22:07:56 2018 +0800
----------------------------------------------------------------------
.../codehaus/groovy/control/ResolveVisitor.java | 76 +++++++++++---------
1 file changed, 42 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/2d1ef39e/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 03acc62..35b51b1 100644
--- a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
@@ -500,6 +500,48 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
return false;
}
+ private boolean resolveFromDefaultImports(final ClassNode type, boolean testDefaultImports) {
+ // test default imports
+ testDefaultImports &= !type.hasPackageName();
+ // we do not resolve a vanilla name starting with a lower case letter
+ // try to resolve against a default import, because we know that the
+ // default packages do not contain classes like these
+ testDefaultImports &= !(type instanceof LowerCaseClass);
+
+ if (testDefaultImports) {
+ if (resolveFromDefaultImports(type)) return true;
+
+ final String typeName = type.getName();
+ if (BIGINTEGER_STR.equals(typeName)) {
+ type.setRedirect(ClassHelper.BigInteger_TYPE);
+ return true;
+ } else if (BIGDECIMAL_STR.equals(typeName)) {
+ type.setRedirect(ClassHelper.BigDecimal_TYPE);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean resolveFromDefaultImports(ClassNode type) {
+ final String typeName = type.getName();
+
+ Set<String> packagePrefixSet = DEFAULT_IMPORT_CLASS_AND_PACKAGES_CACHE.get(typeName);
+ if (null != packagePrefixSet) {
+ // if the type name was resolved before, we can try the successfully resolved packages first, which are much less and very likely successful to resolve.
+ // As a result, we can avoid trying other default import packages and further resolving, which can improve the resolving performance to some extent.
+ if (resolveFromDefaultImports(type, packagePrefixSet.toArray(EMPTY_STRING_ARRAY))) {
+ return true;
+ }
+ }
+
+ if (resolveFromDefaultImports(type, DEFAULT_IMPORTS)) {
+ return true;
+ }
+ return false;
+ }
+
+
private static final EvictableCache<String, Set<String>> DEFAULT_IMPORT_CLASS_AND_PACKAGES_CACHE = new ConcurrentCommonCache<>();
private boolean resolveFromDefaultImports(final ClassNode type, final String[] packagePrefixes) {
@@ -533,40 +575,6 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
return false;
}
- private boolean resolveFromDefaultImports(final ClassNode type, boolean testDefaultImports) {
- // test default imports
- testDefaultImports &= !type.hasPackageName();
- // we do not resolve a vanilla name starting with a lower case letter
- // try to resolve against a default import, because we know that the
- // default packages do not contain classes like these
- testDefaultImports &= !(type instanceof LowerCaseClass);
- final String typeName = type.getName();
-
- if (testDefaultImports) {
- Set<String> packagePrefixSet = DEFAULT_IMPORT_CLASS_AND_PACKAGES_CACHE.get(typeName);
- if (null != packagePrefixSet) {
- // if the type name was resolved before, we can try the successfully resolved packages first, which are much less and very likely successful to resolve.
- // As a result, we can avoid trying other default import packages and further resolving, which can improve the resolving performance to some extent.
- if (resolveFromDefaultImports(type, packagePrefixSet.toArray(EMPTY_STRING_ARRAY))) {
- return true;
- }
- }
-
- if (resolveFromDefaultImports(type, DEFAULT_IMPORTS)) {
- return true;
- }
-
- if (BIGINTEGER_STR.equals(typeName)) {
- type.setRedirect(ClassHelper.BigInteger_TYPE);
- return true;
- } else if (BIGDECIMAL_STR.equals(typeName)) {
- type.setRedirect(ClassHelper.BigDecimal_TYPE);
- return true;
- }
- }
- return false;
- }
-
private boolean resolveFromCompileUnit(ClassNode type) {
// look into the compile unit if there is a class with that name
CompileUnit compileUnit = currentClass.getCompileUnit();