Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.1
-
None
Description
import groovy.transform.* @CompileStatic class Bug3 { String test() { def b = "foo".bytes new String(b) } } new Bug3().test()
Static compilation is not happy with the above, thinking b is a Byte[] instead of byte[], yielding the following error:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[B@727a9fa7' with class '[B' to class 'byte' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:146) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.byteUnbox(DefaultTypeTransformation.java:46) at Bug3.test(ConsoleScript34:7)
Whereas, if you explicitly type the variable with byte[] it's okay.