You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/05/17 19:03:00 UTC
[jira] [Updated] (GROOVY-10316) Type variable inference does not work properly in nested diamond operators
[ https://issues.apache.org/jira/browse/GROOVY-10316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10316:
---------------------------------
Fix Version/s: 4.0.3
> 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
> Assignee: Eric Milles
> Priority: Major
> Fix For: 5.0.0-alpha-1, 4.0.3
>
>
> 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.20.7#820007)