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 2022/11/21 17:48:00 UTC
[jira] [Closed] (GROOVY-10796) TupleConstructor and map-ish constructor style don't mix
[ https://issues.apache.org/jira/browse/GROOVY-10796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles closed GROOVY-10796.
--------------------------------
Resolution: Information Provided
> TupleConstructor and map-ish constructor style don't mix
> --------------------------------------------------------
>
> Key: GROOVY-10796
> URL: https://issues.apache.org/jira/browse/GROOVY-10796
> Project: Groovy
> Issue Type: Bug
> Components: Compiler, Static compilation
> Affects Versions: 4.0.6
> Reporter: Christopher Smith
> Priority: Major
>
> I'm not certain exactly where the semantic breakdown happens, but here's the code setup:
> {code:groovy}
> @TupleConstructor(defaults = false)
> class Foo {
> Map<String, Object> criteria
> }
> ...
> def foo = new Foo(criteria: [fortyTwo: 42])
> {code}
> I expect to have a {{Foo}} object whose {{criteria}} property contains the mapping {{'fortyTwo'=42}}. Instead, I get a nested map:
> {code:groovy}
> assert [criteria: [fortyTwo: 42]] == foo.criteria
> {code}
> I know this has something to do with the map-constructor idiom (which I don't use enough to be familiar with); instead, I expected the {{setCriteria}} shorthand to be generated here. I get the sense that there's a gap in the semantic definitions regarding "Map as the single constructor parameter".
--
This message was sent by Atlassian Jira
(v8.20.10#820010)