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/05/13 14:14:00 UTC

[jira] [Updated] (GROOVY-10624) Nested diamond operators do not work correctly although the expected type argument is known

     [ https://issues.apache.org/jira/browse/GROOVY-10624?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thodoris Sotiropoulos updated GROOVY-10624:
-------------------------------------------
    Description: 
I have the following program:

{code}
class C<T> {
  C(D<T> x) {}
}

class D<T> {}


class Test {
  void test() {
    C<Float> x = new C<>(new D<>()); // type variables are instantiated with type Float because of the left-hand side.
  }

}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 10: [Static type checking] - Incompatible generic argument types. Cannot assign C<java.lang.Object> to: C<java.lang.Float>
 @ line 10, column 18.
       C<Float> x = new C<>(new D<>());
                    ^

1 error
{code}

h3. Expected behavior

Compile successfully

Tested against master (commit: ee12bb52381e8f0583c61fc25d43de1f55b80a87)

  was:
I have the following program:

{code}
class C<T> {
  C(D<T> x) {}
}

class D<T> {}


class Test {
  void test() {
    C<Float> x = new C<>(new D<>());
  }

}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 10: [Static type checking] - Incompatible generic argument types. Cannot assign C<java.lang.Object> to: C<java.lang.Float>
 @ line 10, column 18.
       C<Float> x = new C<>(new D<>()); // type variables are instantiated with type Float because of the left-hand side.
                    ^

1 error
{code}

h3. Expected behavior

Compile successfully

Tested against master (commit: ee12bb52381e8f0583c61fc25d43de1f55b80a87)


> Nested diamond operators do not work correctly although the expected type argument is known
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10624
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10624
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Priority: Major
>
> I have the following program:
> {code}
> class C<T> {
>   C(D<T> x) {}
> }
> class D<T> {}
> class Test {
>   void test() {
>     C<Float> x = new C<>(new D<>()); // type variables are instantiated with type Float because of the left-hand side.
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 10: [Static type checking] - Incompatible generic argument types. Cannot assign C<java.lang.Object> to: C<java.lang.Float>
>  @ line 10, column 18.
>        C<Float> x = new C<>(new D<>());
>                     ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> Tested against master (commit: ee12bb52381e8f0583c61fc25d43de1f55b80a87)



--
This message was sent by Atlassian Jira
(v8.20.7#820007)