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

Inconsistency in extension method selection with @CompileStatic

    XMLWordPrintableJSON

    Details

      Description

      Given properly registered extension class:

      MyExtensions.java
      public class MyExtensions {
      
          public static void foo(Object self, String s) {
              System.out.println("Object#foo(String)");
          }
      
          public static void foo(String self, Object o) {
              System.out.println("String#foo(Object)");
          }
      }
      

      Run

      playground.groovy
      void usageExt() {
          "".foo("") // prints "Object#foo(String)" which is correct
      }
      
      @groovy.transform.CompileStatic
      void usageExtStatic() {
          "".foo("") // prints "String#foo(Object)" which is questionable
      }
      
      usageExt()
      usageExtStatic()
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                daniilo Daniil Ovchinnikov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: