Thodoris Sotiropoulos created GROOVY-10482:
----------------------------------------------

             Summary: Incorrect inference of type argument of parameterized 
method call
                 Key: GROOVY-10482
                 URL: https://issues.apache.org/jira/browse/GROOVY-10482
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


Maybe related to GROOVY-10342

I have the following groovy program

{code:java}
class Foo<T> {
  Foo(T x) {}
}


class Main  {

  static <T> void bar() {
    new Foo<T>(baz());
  }

  static <Z> Z baz() {
    return null;
  }

}
{code}

h3. Actual behaviour

The compiler rejects the code with

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 9: [Static type checking] - Cannot call Foo#<init>(T) with 
arguments [#Z]
 @ line 9, column 5.
       new Foo<T>(baz());
       ^

1 error
{code}

h3. Expected behaviour

Compile successfully.


Tested against 
https://github.com/apache/groovy/commit/5601ea14304b67e71586b0196e38f90fa1a46f5b.



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

Reply via email to