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 2021/11/02 00:56:00 UTC
[jira] [Resolved] (GROOVY-10291) STC fails to substitute type
variable when using the diamond operator and calling a closure
[ https://issues.apache.org/jira/browse/GROOVY-10291?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-10291.
----------------------------------
Fix Version/s: 4.0.0-beta-2
Resolution: Fixed
https://github.com/apache/groovy/commit/cffdc8eda40be102eba6de33d13c4d9179b844ad
> STC fails to substitute type variable when using the diamond operator and calling a closure
> -------------------------------------------------------------------------------------------
>
> Key: GROOVY-10291
> URL: https://issues.apache.org/jira/browse/GROOVY-10291
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-2
>
>
> I have the following program
> {code:java}
> class A<X> {
> X x;
> A(X x) {
> this.x = x
> }
> }
> class Test<T> {
> void foo() {
> def closure = { T p -> "" }
> T y = null
> bar(new A<>(y).x) // works
> closure(new A<>(y).x) // fails
> }
> void bar(T x) {}
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 15: [Static type checking] - Cannot call closure that accepts [T] with [X]
> @ line 15, column 12.
> closure(new A<>(y).x) // fails
> ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Tested against master
--
This message was sent by Atlassian Jira
(v8.3.4#803005)