Calling .properties on a map in Groovy 5
Cédric Champeau <[email protected]> Thu, 6 Nov 2025 15:32:39 +0100
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <CADQzvmkQwRs029psWSc4u+vgjLVHd9D2QmdRh_7=t9Yq2GFJ4Q@mail.gmail.com> |
--0000000000008da9300642edf030
Content-Type: text/plain; charset="UTF-8"
Hi all,
I just wanted to check if this behavior change is intentional in Groovy 5.
Let's take the following code:
def map = [:]
map.put('properties', 123)
assert map.get("properties") == 123
assert map.properties == 123
In Groovy 4.x, this passes. On Groovy 5.0.2, it fails with:
assert map.properties == 123
| | |
| [:] false
['properties':123]
As if the `getProperties()` of the class was taking precedence on a Map.
Thanks,
--0000000000008da9300642edf030
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Hi all,</div><div><br></div><div>I just wanted to che=
ck if this behavior change is intentional in Groovy 5. Let's take the f=
ollowing code:</div><div><br></div><div>def map =3D [:]<br>map.put('pro=
perties', 123)</div><div><br></div><div>assert map.get("properties=
") =3D=3D 123<br>assert map.properties =3D=3D 123<br></div><div><br></=
div><div>In Groovy 4.x, this passes. On Groovy 5.0.2, it fails with:</div><=
div><br></div><div>assert map.properties =3D=3D 123<br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0| =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0| =C2=A0 [:] =C2=A0 =C2=A0 =C2=A0 =C2=A0false<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0['properties':123]<br></div><div><br></div><div>As if =
the `getProperties()` of the class was taking precedence on a Map.</div><di=
v><br></div><div>Thanks,</div></div>
--0000000000008da9300642edf030--