Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
I have the following program
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<>()); } }
Actual behaviour
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
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.
Attachments
Issue Links
- relates to
-
GROOVY-10342 STC is unable to infer type parameter of parameterized method call
- Closed