Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.13, 3.0.0-alpha-3, 2.5.2
-
None
Description
The inferred type of a generic List<? extends X> is wrong.
The minimal reproduceable code is:
import groovy.transform.CompileStatic class A {} class B extends A {} @CompileStatic class TestClassSort { void test() { //List<? extends A> a // without ` = null`, this compiles OK List<? extends A> a = null if(false) { a = new ArrayList<A>() } else { a = new ArrayList<B>() } //BUG: Error: Groovyc: Expected parameter of type ? but got A a.sort({ A v1, A v2 -> return 0 }) } static void main(String []a) { new TestClassSort().test() } }