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

Method ambiguity error when having methods with primitive arrays and varargs

    XMLWordPrintableJSON

Details

    Description

      I have the following program (it uses the apache-commons-lang3 library)

      class Main {
        static final void test() {
          final byte[] vetting = new byte[1];
          final byte[] grafting = org.apache.commons.lang3.ArrayUtils.removeAll(vetting); // works 
          final byte[] grafting = org.apache.commons.lang3.ArrayUtils.removeAll(vetting, 0); // fails 
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      groovy38.groovy: 4: [Static type checking] - Reference to method is ambiguous. Cannot choose between [byte[] org.apache.commons.lang3.ArrayUtils#removeAll(byte[], int[]), long[] org.apache.commons.lang3.ArrayUtils#removeAll(long[], int[]), float[] org.apache.commons.lang3.ArrayUtils#removeAll(float[], int[]), double[] org.apache.commons.lang3.ArrayUtils#removeAll(double[], int[]), int[] org.apache.commons.lang3.ArrayUtils#removeAll(int[], int[]), short[] org.apache.commons.lang3.ArrayUtils#removeAll(short[], int[])]
       @ line 4, column 29.
             final byte[] grafting = org.apache.commons.lang3.ArrayUtils.removeAll(vetting, 0);
                                     ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Tested against master (commit: 7a4b2679c77aea8cd9dc00fa2d3b71e25e97fbd2)

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              theosot Thodoris Sotiropoulos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: