[
https://issues.apache.org/jira/browse/GROOVY-9883?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles resolved GROOVY-9883.
---------------------------------
Resolution: Information Provided
> STC permits heap pollution with closures
> ----------------------------------------
>
> Key: GROOVY-9883
> URL: https://issues.apache.org/jira/browse/GROOVY-9883
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 3.0.7
> Reporter: Christopher Smith
> Priority: Major
>
> The following code automatically coerces the UUID to a String:
> {code:groovy}
> String id = randomUUID()
> println id.class // java.lang.String
> {code}
> However, the following code passes STC but produces the following results:
> {code:groovy}
> Supplier<String> supplier = { randomUUID() } as Supplier // or
> Supplier<String>, no difference
> println supplier.get().class // java.util.UUID
> {code}
> Not sure whether this is related to GROOVY-9882, but they smell alike. This
> behavior seems a bigger problem than the other, as it will allow heap
> pollution. At a minimum, this code should produce a compile-time error
> complaining that the closure's return type does not match {{<String>}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)