daniellansun opened a new pull request, #3345: URL: https://github.com/apache/groovy/pull/3345
https://issues.apache.org/jira/browse/GROOVY-3676 A map literal such as `["${key}": value]` used to store the key as a `GString`. A subscript renders a `GString` to a `String` before `Map.get`, and `String.equals` does not treat a `GString` as equal, so both `map["${key}"]` and `map[key]` returned null while iteration still showed the entry. The literal now stores the `String` from one `toString()` call, taken when the literal is evaluated. That is the same rendering a dynamic subscript assignment already stored. A spread still copies the source map's keys unchanged, so a `GString` passed to `Map.put` stays distinct from the equivalent `String`. `DefaultGroovyMethods.getAt(Map, Object)` looks the `GString` up as itself first and, only when that key is absent, as the rendered `String`. Static inference of such a literal key is now `String`. This is a Groovy 7 behavior change, documented in `COMPATIBILITY.md`. Do not sync to `GROOVY_6_0_X`. Coverage is in `Groovy3676` and the re-enabled `RegressionTest.testGroovy3676`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
