Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
I have the following program
class A<T> { T f; } class Test { static <T> T m() { return null; } static <T extends Number> void test() { String x = m(); // works A<String> y = new A<>(); y.f = m(); // works A<T> z = new A<T>(); z.f = m(); // does not work } }
Actual behaviour
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 15: [Static type checking] - Cannot assign value of type #T to variable of type T @ line 15, column 11. z.f = m(); ^ 1 error
Expected behavior
Compile successfully
NOTE: Replacing `T extends Number` with `T` compiles code successfully.
Tested against master.
Attachments
Issue Links
- is related to
-
GROOVY-7316 CompileStatic cannot infer generic return type
- Closed
-
GROOVY-10067 STC: Wrong return value type inferred for generic method with upper bound without parameters
- Closed
-
GROOVY-10222 Unable to infer the type parameter of a parameterized function
- Closed
-
GROOVY-10256 STC: no error for incompatible type bounds on return value
- Closed
-
GROOVY-10324 STC is unable to infer type variable when combining parameterized types and the diamond operator
- Closed