Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Probably related to GROOVY-9985
import java.util.* class Test { public static void main(String[] args) { List<String> lst = ["fda"]; List<Integer>[] x = new List<Integer>[]{lst}; Integer k = x[0].get(0) } }
Actual behavior
The program compiles but receiving the following runtime error:
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'fda' with class 'java.lang.String' to class 'java.lang.Integer' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:173) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:288) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:245) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:336) at Test.main(test.groovy:7)
Expected behavior
The program should have been rejected