Description
I tried TypeChecked/CompileStatic with calling PrintWriter.write(byte[], int, int) in following code:
//@groovy.transform.CompileStatic @groovy.transform.TypeChecked def main() { byte[] data = [1,2,3] as byte[] System.out.write((byte[])data, (int)0, (int)0) } main()
raises following static type check error:
m.groovy: 11: [Static type checking] - Reference to method is ambiguous. Cannot choose between [MethodNode@1587779925[void write([B, int, int)], MethodNode@1727501758[void write([B)], MethodNode@957941600[void write([B)], MethodNode@902239314[void write([C)]]
@ line 11, column 3.
System.out.write((byte[])data, (int)0, (int)0)
^1 error
When tried without cast operator( System.out.write(data,0,0) ), the result was similar.
When I tried to call method which i defined, no error detected:
@groovy.transform.TypeChecked def foo(byte[] c, int a, int b) {} @groovy.transform.TypeChecked def main() { byte[] data = [1,2,3] as byte[] foo((byte[])data, (int)0, (int)0) } main()