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

Use of overloaded methods with empty/varags parameters fails if type checking is active

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.4
    • 2.1.5
    • None
    • Windows 7, Java 6, Groovy 2.1.4

    Description

      Example 1:

      @groovy.transform.CompileStatic
      class MyClass {
          public static void main(String[] args) {
              def list = ['a', 'b', 'c']
              Object[] arr = list.toArray()
              println arr
          }
      }
      


      Groovyc: [Static type checking] - Reference to method is ambiguous. Cannot choose between [java.lang.Object <T>[] java.util.List <E extends java.lang.Object>#toArray(java.lang.Object <T>[]), java.lang.Object[] java.util.List <E extends java.lang.Object>#toArray()]

      Example 2:

      @CompileStatic
      class JavaFxApp extends Application {
      
          public static void main(String[] args) {
              launch(args);
          }
      
          @Override
          public void start(Stage primaryStage) {
              Group root = new Group();
              root.getChildren().add(new Label('Hello World'));
              primaryStage.setScene(new Scene(root));
              primaryStage.show();
          }
      }
      


      Groovyc: [Static type checking] - Reference to method is ambiguous. Cannot choose between void javafx.scene.Group#<init>(javafx.scene.Node[]), void javafx.scene.Group#<init>()

      Attachments

        Activity

          People

            melix C├ędric Champeau
            bborchardt Brett Borchardt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: