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

Eric Milles updated GROOVY-9882:
--------------------------------
    Fix Version/s: 2.5.16

> STC: field or property with parameterized SAM-type and closure initializer
> --------------------------------------------------------------------------
>
>                 Key: GROOVY-9882
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9882
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.5.14, 3.0.7, 4.0.0-alpha-2
>            Reporter: Christopher Smith
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 3.0.8, 4.0.0-alpha-3, 2.5.16
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> In static mode, the compiler correctly coerces closures that match 
> non-generic SAMs to their concrete type, but this breaks in the context of 
> generics.
> {code:groovy}
> Runnable doIt = { '123' } // works fine
> Supplier<String> supplier = { '123' } // error
> {code}
> The error is
> {code}
> Cannot assign value of type groovy.lang.Closure <java.lang.String> to 
> variable of type java.util.function.Supplier <String>
> {code}
> Not sure if it's relevant that the generic in the second case is reported as 
> bare {{<String>}}. Replacing the type parameter with a literal 
> {{<java.lang.String>}} causes the error message to match but does not fix the 
> error. Using {{<Function<String, String>}} produces matching behavior, so 
> it's not just a "skip java.lang", and in the latter case the reported bound 
> is the raw type {{Function}}.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to