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

STC does not type check method call when using bounded type parameter as a type argument

    XMLWordPrintableJSON

Details

    Description

      I have the following program

      class A<T> {
        void m(B<T> x, T y) {}
      }
      
      class B<T> {}
      
      class Test<X, Y extends X> {
        void m() {
          A<Y> x = new A<Y>();
          x.m(new B<Y>(), (Y) null);
        }
      }
      

      Actual behaviour

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 11: [Static type checking] - Cannot call A#m(B<Y extends X>, Y) with arguments [B<Y>, Y]
       @ line 11, column 5.
             x.m(new B<Y>(), (Y) null);
             ^
      
      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: