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

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

I did look at putAt.  It is declared as "public <K,V> V putAt(Map<K,V> map, K 
key, V val)".  So there is some difference as far as the static compiler is 
concerned.  For "Map<String,?>" it says that GString is not compatible with 
String.  GROOVY-9420 changed this same error for getAt, which now accepts 
Object like Map#get does.

Is there a way to break all this down and proceed with stepwise refinements?  
8788 is about inconsistent selection of extension methods.  I can make the 
static compiler select like the dynamic compiler does (the PR) but there would 
be consequences for map access and some other things like set intersect.  It 
sounds like you explicitly wanted the static compiler to work differently in 
this space.  So is there a play to bring the dynamic compiler in line or should 
we just close this out and accept the difference in bahavior?

> 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