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 2023/01/24 14:50:00 UTC

[jira] [Closed] (GROOVY-9908) STC disregards type witnesses

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

Eric Milles closed GROOVY-9908.
-------------------------------
    Resolution: Cannot Reproduce

> STC disregards type witnesses
> -----------------------------
>
>                 Key: GROOVY-9908
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9908
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 3.0.7
>            Reporter: Christopher Smith
>            Priority: Major
>
> In trying to work around some generics bugs that I think have patches for upcoming versions, I discovered a more basic problem with the STC. I'm having trouble with a standalone reproduction, but I can repro in situ.
> I'm putting together a Gremlin traversal (pretty generics-heavy). Gremlin defines this method, with no constraints on {{A}}:
> {code:java}
> public static <A> GraphTraversal<A, A> start()
> {code}
> I am trying to feed this to a custom method defined on a Java interface:
> {code:java}
> <A extends Element, E2> GraphTraversal<A, Map<Object, E2>> selectProperties(GraphTraversal<A, Vertex> gt);
> {code}
> The solution is that the first {{A}} is {{Vertex}}. However, the simple invocation
> {code:groovy}
> p.selectProperties(__.start())
> {code}
> triggers the STC error
> {code}
> Cannot call <A extends org.apache.tinkerpop.gremlin.structure.Element,E2> com.example.Projector#selectProperties(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal <A, org.apache.tinkerpop.gremlin.structure.Vertex>) with arguments [org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal <A extends java.lang.Object, A extends java.lang.Object>] 
> {code}
> This is a bug but I think already in fixing. The problem I am reporting is that even an explicit type witness, which should tell the STC what it needs, is ignored:
> {code:groovy}
> p.selectProperties(__.<Vertex,Vertex>start())
> {code}
> This produces the same error as above, specifically including the unbound {{A extends Object}} instead of the explicit {{Vertex}}.



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