You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/09/10 10:17:00 UTC
[jira] [Updated] (GROOVY-9699) @CompileStatic does not use bridge
methods for keyed map access
[ https://issues.apache.org/jira/browse/GROOVY-9699?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-9699:
------------------------------
Fix Version/s: (was: 2.5.13)
> @CompileStatic does not use bridge methods for keyed map access
> ---------------------------------------------------------------
>
> Key: GROOVY-9699
> URL: https://issues.apache.org/jira/browse/GROOVY-9699
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Reporter: Leonard Brünings
> Assignee: Eric Milles
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Extracted from GROOVY-9695:
> {code:groovy}
> import java.util.regex.Pattern
> import org.junit.Test
> import groovy.transform.CompileStatic
> class Example {
> @Test
> void testBaseListClass() {
> new Base().checkList()
> }
> @Test
> void testChildListClass() {
> new Child().checkList()
> }
> @Test
> void testBaseMapClass() {
> new Base().checkMap()
> }
> @Test
> void testChildMapClass() {
> new Child().checkMap()
> }
> }
> @CompileStatic
> class Base {
> private static final Pattern PATTERNS = ~/.*Test/
> def checkList() {
> List failures = []
> def closure = {
> failures << PATTERNS.pattern()
> }
> closure()
> }
> def checkMap() {
> Map failures = [:]
> def closure = {
> failures[PATTERNS.pattern()] = 1
> }
> closure()
> }
> }
> class Child extends Base {
> }
> {code}
> For the list it works fine (Procyon Decompiler)
> {code:java}
> public Object doCall(final Object it) {
> return DefaultGroovyMethods.leftShift((List<String>)ScriptBytecodeAdapter.castToType(this.failures.get(), List.class), Base.pfaccess$0((Base)null).pattern());
> }
> {code}
> For the map it doesn't use the bridge method (Procyon Decompiler)
> {code:java}
> public Object doCall(final Object it) {
> final int n = 1;
> DefaultGroovyMethods.putAt((Map<String, Integer>)ScriptBytecodeAdapter.castToType(this.failures.get(), Map.class), ((Pattern)this.getProperty("PATTERNS")).pattern(), n);
> return n;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)