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/06/01 15:52:00 UTC
[jira] [Updated] (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 ]
Eric Milles updated GROOVY-10646:
---------------------------------
Description:
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
was:
Consider the following:
{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
> 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
>
> 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.7#820007)