You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2018/05/11 06:13:00 UTC
[jira] [Resolved] (GROOVY-7985) Wrong "incompatible generic type"
error
[ https://issues.apache.org/jira/browse/GROOVY-7985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun resolved GROOVY-7985.
--------------------------------
Resolution: Fixed
Assignee: Daniel Sun
Fix Version/s: 2.5.0-rc-3
3.0.0-alpha-3
2.6.0-alpha-4
Fixed by https://github.com/apache/groovy/commit/9f14993d9e260a1277311fad78d13bd6f4c8c95f
As for the example in the comment, it relies on 3rd party lib, so I can not verify it right now. Please simplify it and file a new JIRA ticket. Thanks.
> Wrong "incompatible generic type" error
> ---------------------------------------
>
> Key: GROOVY-7985
> URL: https://issues.apache.org/jira/browse/GROOVY-7985
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 2.4.7
> Reporter: Mauro Molinari
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 2.6.0-alpha-4, 3.0.0-alpha-3, 2.5.0-rc-3
>
>
> Consider the following:
> {code}
> package test;
> import java.io.Serializable;
> public final class Pair<L, R> implements Serializable {
> public static <L, R> Pair<L, R> of(final L left, final R right) {
> return new Pair<>(left, right);
> }
> public final L left;
> public final R right;
> private Pair(final L left, final R right) {
> this.left = left;
> this.right = right;
> }
> }
> {code}
> And the following Groovy class:
> {code}
> package test2
> import test.Pair
> import java.util.Date;
> import groovy.transform.CompileStatic
> @CompileStatic
> class Test {
> Pair<Pair<Integer, Pair<String, Date>>, Pair<Integer, Pair<String, Date>>> doSmething() {
> def left = (Pair<Integer, Pair<String, Date>>) null
> def right = (Pair<Integer, Pair<String, Date>>) null
> return Pair.of(left, right)
> }
> }
> {code}
> Compilation fails with the following error message:
> {noformat}
> [Static type checking] - Incompatible generic argument types. Cannot assign test.Pair <test.Pair, test.Pair> to: test.Pair <Pair, Pair>
> @ line 15, column 10.
> return Pair.of(left, right)
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)