Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.9, 2.2.0-rc-3
-
None
Description
A static type checking error "[Static type checking] - Cannot assign value of type MyInteger to variable of type java.math.BigInteger" when assigning child class of BigInteger to a BigInteger variable. Occurs only from static context when @CompileStatic enabled. Does not occur for similar case for BigDecimal.
Example:
public class MyDecimal extends java.math.BigDecimal { public MyDecimal(String s) {super(s);} } public class MyInteger extends java.math.BigInteger { public MyInteger(String s) {super(s);} } public class Foo { @groovy.transform.CompileStatic public static void run() { BigDecimal d = new MyDecimal("3.0"); BigInteger i = new MyInteger("3"); //compile error: [Static type checking] } } Foo.run();