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/10/04 13:47:00 UTC

[jira] [Created] (GROOVY-10280) Type variable substitution does not work well when running into chain of field accesses

Thodoris Sotiropoulos created GROOVY-10280:
----------------------------------------------

             Summary: Type variable substitution does not work well when running into chain of field accesses
                 Key: GROOVY-10280
                 URL: https://issues.apache.org/jira/browse/GROOVY-10280
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following program

{code:java}
class Foo<T> {
  T foo() {
    new Bar<T>().f1.f2.f3;
  }
  
}

class Bar<Y> {
  Baz<Y> f1;
}

class Baz<T> {
  Qux<T> f2;
}

class Qux<X> {
  X f3;
}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 3: [Static type checking] - Cannot return value of type Y on method returning type T
 @ line 3, column 5.
       new Bar<T>().f1.f2.f3;
       ^

1 error
{code}


h3. Expected behavior

Compile successfully

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



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