Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10379

Error for super class and super interface methods of same name

    XMLWordPrintableJSON

Details

    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)
      

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: