Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.7, 2.4.0-beta-3
-
None
Description
Groovy code:
@groovy.transform.CompileStatic void test() { Number[] ary ary = [1] as Integer[] ary[0] = null ary = [1] as Number[] } test()
This generates this error message.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: C:\Users\Yu\Desktop\test2.groovy: 5: [Static type checking] - Cannot call <T,U extends T> java.lang.Integer[]#putAt(int, U) with arguments [int, java.lang.Object] @ line 5, column 5. ary[0] = null ^
If I remove "ary = [1] as Number[]" the compile error does not happen.
I think this is a flow typing bug.
Also If I change this code from "ary[0] = null" to "ary[0] = 2",
@groovy.transform.CompileStatic void test() { Number[] ary ary = [1] as Integer[] ary[0] = 2 ary = [1] as Number[] } test()
the error message is this.
Caught: java.lang.IllegalAccessError: tried to access class org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport$ObjectArrayStaticTypesHelper from class test2 java.lang.IllegalAccessError: tried to access class org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport$ObjectArrayStaticTypesHelper from class test2 at test2.test(test2.groovy:5) at test2.run(test2.groovy:8)