Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.3.4
-
None
Description
In the following code, the type of myVar variable is of type Base instead of Derived. This behavior is different than Java.
class Base {} class Derived extends Base { public void sayHello() { System.out.println("hello"); } } class GBase<T extends Base>{ T myVar; } @CompileStatic class GDerived extends GBase<Derived> { GDerived() { myVar = new Derived(); } public void method() { // Groovy compiler thinks myVar is of type base and doesn't have sayHello myVar.sayHello(); } } public class Main { public static void main(String[] args) { GDerived d = new GDerived(); d.method(); } }