[ https://issues.apache.org/jira/browse/GROOVY-8788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17582993#comment-17582993 ]
Eric Milles commented on GROOVY-8788: ------------------------------------- First of all, thank you for taking the time to read through all this and provide feedback. Now we come to the hard decisions. {{getAt(Object,String)}} is chosen over {{getAt(Map,Object)}} for dynamic runtime and now STC for String input. As you can see from all the test failures, this goes against expectations because the inferred return type is Object not the map's value type. There is an edge case where this bears out now: {code:groovy} class A { } class B { } class HM extends HashMap<String,A> { B b = new B() } map = new HM() map['a'] = new A() A value = map['a'] value = map['b'] // Groovy 5 returns the property declared by HM (GROOVY-5001, GROOVY-5491, GROOVY-6144) {code} https://github.com/apache/groovy/blame/c18411fe233bd60d4d045d65d9bb04b459f95e12/src/main/java/groovy/lang/MetaClassImpl.java#L1966 > Inconsistency in extension method selection with @CompileStatic > --------------------------------------------------------------- > > Key: GROOVY-8788 > URL: https://issues.apache.org/jira/browse/GROOVY-8788 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker > Affects Versions: 2.4.15, 2.5.2 > Reporter: Daniil Ovchinnikov > Assignee: Eric Milles > Priority: Major > Labels: breaking > > Given properly registered extension class: > {code:java|title=MyExtensions.java} > public class MyExtensions { > public static void foo(Object self, String s) { > System.out.println("Object#foo(String)"); > } > public static void foo(String self, Object o) { > System.out.println("String#foo(Object)"); > } > } > {code} > Run > {code:java|title=playground.groovy} > void usageExt() { > "".foo("") // prints "Object#foo(String)" which is correct > } > @groovy.transform.CompileStatic > void usageExtStatic() { > "".foo("") // prints "String#foo(Object)" which is questionable > } > usageExt() > usageExtStatic() > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)