[
https://issues.apache.org/jira/browse/GROOVY-10631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17540449#comment-17540449
]
Thodoris Sotiropoulos edited comment on GROOVY-10631 at 5/21/22 4:45 PM:
-------------------------------------------------------------------------
You are right. But in this case, the type of variable x is explicitly provided
as A<? extends Object>, which I think it might help finally determine the type
variable T. But I agree this depends on the design of the type inference engine.
was (Author: theosot):
You are right. But in this case, the type of variable x is explicitly provided
as A<? extends Object>, which I think it might help finally determine the type
variable T.
> Unable to instantiate type parameter of method with a valid type
> ----------------------------------------------------------------
>
> Key: GROOVY-10631
> URL: https://issues.apache.org/jira/browse/GROOVY-10631
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
>
> I have the following program
> {code}
> class A<T> {}
> class Test {
> static <T> T m(T x, T y) { return null; }
> static void test() {
> A<? extends Object> x = m(new A<Boolean>(), new A<String>());
> }
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> test.groovy: 8: [Static type checking] - Cannot call <T> Test#m(T, T) with
> arguments [A<java.lang.Boolean>, A<java.lang.String>]
> @ line 8, column 33.
> A<? extends Object> x = m(new A<Boolean>(), new A<String>());
> ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> Tested against master (commit: a976ecdee1f17f7fafc55767de2d857c44d44697)
--
This message was sent by Atlassian Jira
(v8.20.7#820007)