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

STC is unable to call parameterized function

    XMLWordPrintableJSON

Details

    Description

      I have the following program

      
      class A<T> {
        T f;
        A(T f) {
          this.f = f;
        }
      
        A() {}
      }
      
      class B<T> {}
      
      class Test {
        static <T> A<T> test(T x, B<? extends T> z) {
          return new A<>(x);
        }
      
        public static void main(String[] args) {
          var d = "d";
          test(d, new B<>());
        }
      
      }
      

      Actual behaviour

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 20: [Static type checking] - Cannot call <T> Test#test(T, B<? extends java.lang.Object>) with arguments [java.lang.String, B<java.lang.Object extends T>]
       @ line 20, column 5.
             test(d, new B<>());
             ^
      
      1 error
      

      Expected behaviour

      Compile successfully

      Tested against master

      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: