Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re
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;

Expand Down
10 changes: 9 additions & 1 deletion src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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"
}
Expand Down