Thodoris Sotiropoulos created GROOVY-10351:
----------------------------------------------

             Summary: Wrong type argument is inferred on combining use-site 
variance and diamond operator
                 Key: GROOVY-10351
                 URL: https://issues.apache.org/jira/browse/GROOVY-10351
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


This bug may be related to GROOVY-10337.

I have the following program
{code:java}
class A<T> {
  A(T f, B<T, ? extends T> x){  } 
}

class B<T1, T2> {}

class Test {
  void test() {
    B<Integer, ? extends Integer> x = null;
    A<Integer> y = new A<>(1, x);
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 10: [Static type checking] - Incompatible generic argument types. 
Cannot assign A<? extends java.lang.Object> to: A<java.lang.Integer>
 @ line 10, column 20.
       A<Integer> y = new A<>(1, x);
                      ^

1 error
{code}

h3. Expected behaviour

Compile successfully

Tested against master 
(https://github.com/apache/groovy/commit/de17150ee844a943c070c01c07b81fd547ff074d).



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

Reply via email to