interface Foo {
Function1<String, String> x = { it.substring(1) }
}
class Bar {
static Function1<String, String> x = { it.substring(1) }
public static void main(String[] args) {
println x('abc')
println Foo.x('abc')
}
}
----------
fails at runtime:
bc
Exception in thread "main" java.lang.ExceptionInInitializerError
at Bar.main(test.gpp:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot
cast object 'Foo$__clinit__closure2@26914f6a' with class
'Foo$__clinit__closure2' to class 'groovy.lang.Function1'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:331)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)
at Foo.<clinit>(test.gpp)
... 6 more
Original issue reported on code.google.com by gromop...@gmail.com on 14 Aug 2011 at 3:12
Original issue reported on code.google.com by
gromop...@gmail.com
on 14 Aug 2011 at 3:12