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

STC involves improper subtyping rules for parameterized types with wildcard types

    XMLWordPrintableJSON

Details

    Description

      The following program should not type check

      class A<T> {}
      
      class B<T> extends A<T> {}
      
      class Test {
        B<? extends Number> x = new B<Double>();
        A<Number> y = x;
      }
      

      Expected behaviour

      the compiler should have rejected the program and produced an error of the form (like javac does):

       error: incompatible types: B<CAP#1> cannot be converted to A<Number>
        A<Number> y = x;
                      ^
        where CAP#1 is a fresh type-variable:
          CAP#1 extends Number from capture of ? extends Number
      1 error
      

      Tested against master

      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: