Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.7, 2.4.8
-
None
-
None
Description
@CompileStatic // works without this @CompileStatic class Outer { def foo = 1 Inner createInner() { new Inner() } class Inner { Closure createClosure() { return { foo } } } } @CompileStatic class Main { static void main(String[] args) { def i = new Outer().createInner() def cl = i.createClosure() println cl() } }
Fail in runtime with:
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'Outer$Inner@23e028a9' with class 'Outer$Inner' to class 'Outer' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:405) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:319) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:232) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:603) at Outer$Inner$_createClosure_closure1.doCall(innerclassestest.groovy) at Outer$Inner$_createClosure_closure1.call(innerclassestest.groovy) at Main.main(innerclassestest.groovy:23)
Attachments
Issue Links
- is related to
-
GROOVY-8050 Reference outer class property via inner class
- Closed