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/07/21 07:48:00 UTC

[jira] [Created] (GROOVY-10698) Fail to infer the type argument when using nested diamond operator

Thodoris Sotiropoulos created GROOVY-10698:
----------------------------------------------

             Summary: Fail to infer the type argument when using nested diamond operator
                 Key: GROOVY-10698
                 URL: https://issues.apache.org/jira/browse/GROOVY-10698
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following program

{code}
class A<T> {
  A(T x, B<T> y) {}
}

class B<X> {}


class Test {
  void test() {
    new A<>("fda", new B<>())
  }
}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 10: [Static type checking] - Cannot call A#<init>(java.lang.Object, B<java.lang.Object>) with arguments [java.lang.String, B<T>]
 @ line 10, column 5.
       new A<>("fda", new B<>())
       ^

1 error
{code}

h3. Expected behavior

Compile successfully.

Tested against master (commit: 63bcab1bf13fb3811626fb1727c22e86528feb7f)

**Notes:**
   - this bug occurs when the type parameters of class A and B involve different names
   - this bug is not triggered is groovy 4.0.2. It is introduced in groovy 4.0.3.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)