You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/02/10 21:40:00 UTC

[jira] [Closed] (GROOVY-10646) STC: outer class type parameter inference

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

Paul King closed GROOVY-10646.
------------------------------

> STC: outer class type parameter inference
> -----------------------------------------
>
>                 Key: GROOVY-10646
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10646
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.5
>
>
> Consider the following (extracted from mybatis SelectDSLCompleter):
> {code:groovy}
> class Model {
> }
> interface Output<T> {
>   T build()
> }
> abstract class Input<T> extends QueryDSL<Inner> implements Output<T> {
>   class Inner implements Output<T> {
>     @Override T build() { }
>   }
> }
> abstract class QueryDSL<X> {
>   abstract X where()
> }
> @FunctionalInterface
> interface Func extends Function<Input<Model>, Output<Model>> {
> }
> void select(Func func) {
> }
> @groovy.transform.TypeChecked
> void test() {
>   select { input -> input.where() } // Cannot return value of type Inner for closure expecting Output<Model>
> }
> {code}
> "input" is inferred correctly to be of type "Input<Model>" which should lead to an "Inner" return type for "where()" that implements "Output<Model>".  Some context is lost along the way and "Output<Object>" is inferred instead.
> https://github.com/groovy/groovy-eclipse/issues/1364



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