[ 
https://issues.apache.org/jira/browse/GROOVY-10291?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-10291:
---------------------------------
    Fix Version/s: 3.0.13

> 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, 3.0.13
>
>
> 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.20.10#820010)

Reply via email to