Thodoris Sotiropoulos created GROOVY-10324: ----------------------------------------------
Summary: STC is unable to infer type variable when combining parameterized types and the diamond operator Key: GROOVY-10324 URL: https://issues.apache.org/jira/browse/GROOVY-10324 Project: Groovy Issue Type: Bug Reporter: Thodoris Sotiropoulos I have the following program {code:java} class A { <T> T foo(C<T> t) { return null; } } class C<T> {} class B { void test() { C<String> x = (new A()).foo(new C<>()); } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 12: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type C<java.lang.String> @ line 12, column 19. C<String> x = (new A()).foo(new C<>()); ^ 1 error {code} h3. Expected behaviour Compile successfully Note that compilation fails only if the expected return type is parameterized (i.e., `D<String>`). If I replace the declared type of `x` with a regular type (i.e., `String`), the code compiles fine. Tested against master. -- This message was sent by Atlassian Jira (v8.3.4#803005)