Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Extracted from GROOVY-9695:
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 { }
For the list it works fine (Procyon Decompiler)
public Object doCall(final Object it) { return DefaultGroovyMethods.leftShift((List<String>)ScriptBytecodeAdapter.castToType(this.failures.get(), List.class), Base.pfaccess$0((Base)null).pattern()); }
For the map it doesn't use the bridge method (Procyon Decompiler)
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; }
Attachments
Issue Links
- relates to
-
GROOVY-9695 Regression for accessing private static constants in closures from Parent Classes
- Closed