[ 
https://issues.apache.org/jira/browse/GROOVY-8788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17582543#comment-17582543
 ] 

Eric Milles commented on GROOVY-8788:
-------------------------------------

If my understanding of #1-#5 is consistent, this commit does work to fix the 
self-type weighting of STC/SC: 
https://github.com/apache/groovy/pull/1766/commits/488f8a8f336efae32349317f219a8f8df8994114

I can separate out the getAt change if that helps.  There will be some fallout 
to having {{getAt(Object,String)}} selected over {{getAt(Map<K,V>,Object)}}.

And based on all this, I actually noticed that the javadoc assertions for 
{{getAt(Map<K,V>,Object)}} are not even targeting that method.  They go to 
{{getAt(Object,String)}} because they use string keys.

Further, because {{getAt(Object,String)}} is implemented via getProperty, there 
is an edge case where you can extend map and declare a property, which is what 
this refers to (edited to reflect current behavior):
{code:groovy}
class HM extends HashMap {
  String a = 'x'
}
map = new HM()
map.put("a",1)
assert map["a"] == 'x'
{code}

> 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)

Reply via email to