Thodoris Sotiropoulos created GROOVY-10316:
----------------------------------------------

             Summary: Type variable inference does not work properly in nested 
diamond operators
                 Key: GROOVY-10316
                 URL: https://issues.apache.org/jira/browse/GROOVY-10316
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following program

{code:java}
class A<T> {
  T f;
  A(T f) {
    this.f = f;
  }
}

class B<T> {
  A<T> f;
  B(A<T> f) {
    this.f = f;
  }
}

class Test {
  void test() {
    def x = new  B<>(new A<>((long) 1)).f;
    A<Long> y = x;
  }
  
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 18: [Static type checking] - Incompatible generic argument types. 
Cannot assign A<java.lang.Object> to: A<java.lang.Long>
 @ line 18, column 17.
       A<Long> y = x;
                   ^

1 error
{code}

h3. Expected behaviour

Compile successfully

Tested against master



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to