Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
Description
I have the following program
import java.util.function.*; class A{ } class Test { public static void main(String[] args) { Function<Object, A[]> x = A[]::new; A[] y = x.apply(new Object()); } }
Actual behavior
The code compiles, and I get a ClassCastException:
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'java.lang.Object@63d4e2ba' with class 'java.lang.Object' to class 'int' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:177) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.intUnbox(DefaultTypeTransformation.java:85) at Test.ctorRef$main$0(test.groovy) at Test.main(test.groovy:13)
Actual behavior
The code should have been rejected.