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

Unable to initialize generic class with an array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Static Type Checker

    Description

      Probably a regeression.

      I have the following program

      class Foo<T> {
        Foo(T[] x) {}
      }
      
      class Main {
        static final void test() {
          Byte[][] arg = null;
          Foo<Byte[]> res = new Foo<Byte[]>(arg)
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 8: [Static type checking] - Cannot call Foo#<init>(java.lang.Byte[][]) with arguments [java.lang.Byte[][]]
       @ line 8, column 23.
             Foo<Byte[]> res = new Foo<Byte[]>(arg)
                               ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Notes

      Tested against master

      adapted from the following program

      class Main {
        static final void test() {
          byte[][] arg = null;
          byte[] res = new com.fasterxml.jackson.databind.util.ArrayIterator<byte[]>(arg).next();
        }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: