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 2022/05/20 08:30:00 UTC

[jira] [Created] (GROOVY-10629) Subtyping does not work properly when having two bounded type parameters

Thodoris Sotiropoulos created GROOVY-10629:
----------------------------------------------

             Summary: Subtyping does not work properly when having two bounded type parameters
                 Key: GROOVY-10629
                 URL: https://issues.apache.org/jira/browse/GROOVY-10629
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following program

{code}
class A<T> {
  void m(T x) {}
}


class B<X extends Number, Y extends X> {
  void test() {
    A<X> x = new A<X>();
    x.m((Y) null);
  }
}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 9: [Static type checking] - Cannot call A#m(X) with arguments [Y]
 @ line 9, column 5.
       x.m((Y) null);
       ^

1 error
{code}

h3. Expected behavior

Compile successfully

Note: This bug occurs only when the type variable X is also bounded.

Tested against master (commit: a976ecdee1f17f7fafc55767de2d857c44d44697)



--
This message was sent by Atlassian Jira
(v8.20.7#820007)