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

STC rejects program on compiling constructor initialization with a wildcard type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-beta-2
    • Static Type Checker
    • None

    Description

      I have the following program

      class A<T1, T2> {
        A(A<T2, ? extends T2> y) {}
      }
      
      class Test<T> {
        void test() {
          A<Number, T> x = new A<Number, T>((A<T, T>) null);
        }
      }
      

      Actual behaviour

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 7: [Static type checking] - Cannot call A#<init>(A<T, ? extends java.lang.Object>) with arguments [A<T, T>]
       @ line 7, column 22.
             A<Number, T> x = new A<Number, T>((A<T, T>) null);
                              ^
      
      1 error
      
      

      Expected behaviour

      Compile successfully

      Tested against master (commit: https://github.com/apache/groovy/commit/936983152430a7c030522126eb9e505c04cfb575)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: