You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/11/16 15:28:00 UTC

[jira] [Created] (GROOVY-10371) STC involves improper subtyping rules for parameterized types with wildcard types

Thodoris Sotiropoulos created GROOVY-10371:
----------------------------------------------

             Summary: STC involves improper subtyping rules for parameterized types with wildcard types
                 Key: GROOVY-10371
                 URL: https://issues.apache.org/jira/browse/GROOVY-10371
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


The following program should not type check

{code:java}
class A<T> {}

class B<T> extends A<T> {}

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

h3. Expected behaviour

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

{code}
 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
{code}

Tested against master



--
This message was sent by Atlassian Jira
(v8.20.1#820001)