[
https://issues.apache.org/jira/browse/GROOVY-9699?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles reassigned GROOVY-9699:
-----------------------------------
Assignee: Eric Milles
> @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
> Fix For: 2.5.13
>
>
> 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)