Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
I have the following program
class A<T> { T f; public A(T f) { this.f = f; } } class Foo {} class Bar extends Foo {} public class Main { public static void bar(Foo x) { if (x instanceof Bar) { A<Bar> a = new A<>(x) } } }
Actual Behavior
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 15: [Static type checking] - Incompatible generic argument types. Cannot assign A <Foo> to: A <Bar> @ line 15, column 18. A<Bar> a = new A<>(x) ^1 error
Expected Behavior
Compile successfully
Tested against https://github.com/apache/groovy/commit/359be2b662be646d2d59db8b999412691891231d