You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by sh...@apache.org on 2015/12/29 16:22:23 UTC
groovy git commit: GROOVY-7702: @CompileStatic and the method
with(Closure) seem to determine wrong type (closes #227)
Repository: groovy
Updated Branches:
refs/heads/master 173459be2 -> 38d681ca4
GROOVY-7702: @CompileStatic and the method with(Closure) seem to determine wrong type
(closes #227)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/38d681ca
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/38d681ca
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/38d681ca
Branch: refs/heads/master
Commit: 38d681ca46f075f6d6abcd65c7cf203352d0852d
Parents: 173459b
Author: Shil Sinha <sh...@apache.org>
Authored: Mon Dec 28 17:16:09 2015 -0500
Committer: Shil Sinha <sh...@apache.org>
Committed: Tue Dec 29 09:15:38 2015 -0500
----------------------------------------------------------------------
.../groovy/transform/stc/StaticTypeCheckingVisitor.java | 2 +-
.../transform/stc/FieldsAndPropertiesSTCTest.groovy | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/38d681ca/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index ecaecf7..bf428af 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -1225,7 +1225,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
if (storeProperty(propertyNode, pexp, current, visitor, receiver.getData())) return true;
boolean isThisExpression = objectExpression instanceof VariableExpression &&
- ((VariableExpression) objectExpression).isThisExpression();
+ ((VariableExpression) objectExpression).isThisExpression() && objectExpressionType.equals(current);
if (storeField(field, isThisExpression, pexp, receiver.getType(), visitor, receiver.getData()))
return true;
http://git-wip-us.apache.org/repos/asf/groovy/blob/38d681ca/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
index f12b555..90ce986 100644
--- a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
+++ b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
@@ -568,7 +568,7 @@ class FooWorker {
}
}
-new FooWorker().doSomething()''', 'Incompatible generic argument types. Cannot assign java.util.ArrayList <Integer> to: java.util.List <String>'
+new FooWorker().doSomething()''', 'Cannot assign value of type java.util.ArrayList <Integer> to variable of type java.util.List <String>'
}
void testAICAsStaticProperty() {
@@ -731,6 +731,14 @@ import org.codehaus.groovy.ast.stmt.AssertStatement
'''
}
+ void testImplicitPropertyOfDelegateShouldNotPreferField() {
+ assertScript '''
+ Calendar.instance.with {
+ Date d1 = time
+ }
+ '''
+ }
+
public static interface InterfaceWithField {
String boo = "I don't fancy fields in interfaces"
}