Skip to content

Commit

Permalink
GROOVY-9963
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 5, 2021
1 parent f47e868 commit 783164f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1067,4 +1067,27 @@ public void testTypeChecked9956b() {
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign C <Number> to: A <String>\n" +
"----------\n");
}

@Test
public void testTypeChecked9963() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.TupleConstructor\n" +
"class C<T> {\n" +
" T p\n" +
"}\n" +
"static m(String s) {\n" +
" print s\n" +
"}\n" +
"@groovy.transform.TypeChecked\n" +
"static test() {\n" +
" m(new C<>('x').p)\n" +
"}\n" +
"test()\n",
};
//@formatter:on

runConformTest(sources, "x");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,11 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re

Expression objectExpression = pexp.getObjectExpression();
ClassNode objectExpressionType = getType(objectExpression);
// GRECLIPSE add -- GROOVY-9963
if (objectExpression instanceof ConstructorCallExpression) {
inferDiamondType((ConstructorCallExpression) objectExpression, objectExpressionType);
}
// GRECLIPSE end
List<ClassNode> enclosingTypes = typeCheckingContext.getEnclosingClassNodes();
boolean staticOnlyAccess = isClassClassNodeWrappingConcreteType(objectExpressionType);
if ("this".equals(propertyName) && staticOnlyAccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,11 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re

Expression objectExpression = pexp.getObjectExpression();
ClassNode objectExpressionType = getType(objectExpression);
// GRECLIPSE add -- GROOVY-9963
if (objectExpression instanceof ConstructorCallExpression) {
inferDiamondType((ConstructorCallExpression) objectExpression, objectExpressionType);
}
// GRECLIPSE end
List<ClassNode> enclosingTypes = typeCheckingContext.getEnclosingClassNodes();

boolean staticOnlyAccess = isClassClassNodeWrappingConcreteType(objectExpressionType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,11 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re

Expression objectExpression = pexp.getObjectExpression();
ClassNode objectExpressionType = getType(objectExpression);
// GRECLIPSE add -- GROOVY-9963
if (objectExpression instanceof ConstructorCallExpression) {
inferDiamondType((ConstructorCallExpression) objectExpression, objectExpressionType);
}
// GRECLIPSE end
List<ClassNode> enclosingTypes = typeCheckingContext.getEnclosingClassNodes();

boolean staticOnlyAccess = isClassClassNodeWrappingConcreteType(objectExpressionType);
Expand Down

0 comments on commit 783164f

Please sign in to comment.