Christopher Smith created GROOVY-10796:
------------------------------------------

             Summary: 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


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)

Reply via email to