Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.5.15, 4.0.0-beta-1, 3.0.9
-
None
Description
I have the following program
class Foo { void bar(int x = "str") { System.out.println(x) } } class Main { public static void main(String[] args) { (new Foo()).bar() } }
Actual Behaviour
Runtime error
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'fda' with class 'java.lang.String' to class 'int' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:172) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.intUnbox(DefaultTypeTransformation.java:81) at Foo.bar(test.groovy) at Main.main(test.groovy:10)
Expected Behaviour
Compile-time error
Tested against https://github.com/apache/groovy/commit/867aa7041cfc790d01828591f72996099ff2439f