Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
I have the following Groovy program.
@groovy.transform.CompileStatic public class Main { public static void main(String[] args) { final A<Integer> x = new A<>(null); baz(x); } public static void baz(A<Integer> x) {} } class A<T> { T f; public A(T f) { this.f = f; } }
Actual Behavior
The program does not compile, and I get the following error.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Test.groovy: 4: [Static type checking] - Incompatible generic argument types. Cannot assign A <java.lang.Object> to: A <Integer> @ line 4, column 26. final A<Integer> x = new A<>(null); ^ Test.groovy: 5: [Static type checking] - Cannot call Main#baz(A <java.lang.Integer>) with arguments [A <java.lang.Object>] @ line 5, column 5. baz(x); ^ 2 errors
Expected Behavior
Compile successfully.
Comment
This should be a regression bug because it compiles with the 4.0.0-alpha-2 compiler.
Affected Version
This programs fails when compiled with the compiler from the master (commit: f0eea862549529ef4e93fafe337f86dd4ac98751).