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:46:00 UTC
[jira] [Created] (GROOVY-10646) STC: outer class type parameter inference
Eric Milles created GROOVY-10646:
------------------------------------
Summary: 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
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
--
This message was sent by Atlassian Jira
(v8.20.7#820007)