ajwang / groovypptest

Automatically exported from code.google.com/p/groovypptest
0 stars 0 forks source link

No SAM conversion in interfaces #396

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago

Original comment by alex.tka...@gmail.com on 24 Aug 2011 at 8:02