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 2021/10/17 18:48:00 UTC

[jira] [Resolved] (GROOVY-9500) Goorvy 3 Compilation Failure issue with Generics and same type argument name

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

Eric Milles resolved GROOVY-9500.
---------------------------------
    Resolution: Fixed

Fixed somewhere in Groovy 3 and Groovy 4

> Goorvy 3 Compilation Failure issue with Generics and same type argument name
> ----------------------------------------------------------------------------
>
>                 Key: GROOVY-9500
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9500
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 3.0.1, 3.0.2, 3.0.3
>            Reporter: Puneet Behl
>            Assignee: Eric Milles
>            Priority: Major
>
> While upgrading GORM for Neo4j to support Groovy 3, we are seeing an issue with generics as:
> {code:java}
> [Static type checking] - Cannot return value of type grails.neo4j.Path$Segment <S, E> on method returning type T
>  @ line 81, column 16.
>  return end
>  ^
> 1 error
> {code}
>  
> I believe the problem is with using same name of type argument in the Generics for multiple classes as in the following code:
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.function.Consumer
> @CompileStatic
> abstract class Path<F extends Neo4jEntity, T extends Neo4jEntity> implements Iterable<Segment<F,T>> {
>     T end
>     interface Segment<F, T> {
>         F start()
>         T end()
>     }
>     abstract F start()
>     T end() {
>         return end
>     }
>     @Override
>     void forEach(Consumer<? super Segment<F, T>> action) { }
>     @Override
>     Spliterator<Segment<F, T>> spliterator() {
>         return null
>     }
>     @Override
>     Iterator<Segment<F, T>> iterator() {
>         return null
>     }
> }
> trait Neo4jEntity<D> {
> }
> println GroovySystem.version
> {code}
> *Please note that* If we replace `F` and `T` in the above code with `S` and `E` the code will compile successfully.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)