Details
Description
In following code, the second assert fails.
@groovy.transform.CompileStatic def main(){ boolean[] flags1 = new boolean[10] assert flags1.class == boolean[] assert flags1.size() == 10 // OK def flags2 = new boolean[10] // dynamic type assert flags2.class == boolean[] assert flags2.size() == 10 // LHS is 1(not expected) } main()
I tried also int[] instead of boolean[]
@groovy.transform.CompileStatic def main(){ int[] flags1 = new int[10] assert flags1.class == int[] assert flags1.size() == 10 // OK def flags2 = new int[10] // dynamic type assert flags2.class == int[] assert flags2.size() == 10 // Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[I@3b845321' with class '[I' to class 'int' } main()
When remove CompileStatic annotation, above are no problem.
Using @TypeChecked instead of @CompileStatic claims nothing.
I think it is a problem about the code generated by CompileStatic or type inference.