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 2022/04/27 08:34:00 UTC
[jira] [Closed] (GROOVY-10499) Incomplete type variable substitution when using wildcard type and diamond operator
[ https://issues.apache.org/jira/browse/GROOVY-10499?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-10499.
------------------------------
> Incomplete type variable substitution when using wildcard type and diamond operator
> -----------------------------------------------------------------------------------
>
> Key: GROOVY-10499
> URL: https://issues.apache.org/jira/browse/GROOVY-10499
> Project: Groovy
> Issue Type: Bug
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 5.0.0-alpha-1, 4.0.2
>
>
> I have the following groovy program
> {code:java}
> class Foo<T> {
> Foo(T x) {}
> }
> class Bar<T> {
> Bar(Foo<? extends T> foo, T p) {
> }
> T m(T x) {
> return null;
> }
> }
> public class Test<T> {
> void test() {
> T x = null;
> new Bar<>(new Foo<T>(x), x).m(x);
> }
> }
> {code}
> h3. Actual behaviour
> groovyc rejects the program by raising
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 20: [Static type checking] - Cannot find matching method Bar#m(T). Please check if the declared type is correct and if the method exists.
> @ line 20, column 5.
> new Bar<>(new Foo<T>(x), x).m(x);
> ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully.
> The bug happens when:
> * The constructor of `Bar` expects a parameterized type containing a wildcard type (i.e., `Foo<? extends T>`
> * The constructor of `Bar` expects something of type `T` (i.e., `T p`).
> Tested against master (commit: 85676f1855bbe751bac897ea3fdd900fbbe74ecb).
--
This message was sent by Atlassian Jira
(v8.20.7#820007)