You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Christopher Smith (Jira)" <ji...@apache.org> on 2022/11/03 20:13:00 UTC
[jira] [Created] (GROOVY-10809) Set coercion doesn't "pull through" method resolution
Christopher Smith created GROOVY-10809:
------------------------------------------
Summary: Set coercion doesn't "pull through" method resolution
Key: GROOVY-10809
URL: https://issues.apache.org/jira/browse/GROOVY-10809
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Affects Versions: 4.0.6
Reporter: Christopher Smith
In the usual case, the brackets syntax for an inline collection is implemented as an {{ArrayList}} but can become {{LinkedHashSet}} if the expression type is determined to be {{Set}}. However, this doesn't work if {{.asImmutable()}} is applied, because the expression is definitively identified as {{List}} first.
{code:groovy}
Set<String> WORKS = ["a"]
Set<String> ALSO_WORKS = (["b"] as Set).asImmutable()
Set<String> FAILS = ["c"].asImmutable()
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)