Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-beta-2
-
None
Description
Follow up to GROOVY-9737. Another variation of static and non-static (interface default in this case) methods of the same name. Consider the following:
package p abstract class A implements I { static void m(Number n) { print 'number' } }
package p; public interface I { default void m(String s) { System.out.print("string"); } }
@groovy.transform.CompileStatic class C extends p.A { void test() { m('') // error at run-time } } new C().test()
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'class C' with class 'java.lang.Class' to class 'p.I' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:420) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:331) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:251) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318) at C.test(Main.groovy:4) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318) at Main.run(Main.groovy:7)