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

ASF GitHub Bot commented on GROOVY-8788:
----------------------------------------

eric-milles commented on PR #1766:
URL: https://github.com/apache/groovy/pull/1766#issuecomment-1219738720

   With the addition of `getAt(Map,String)` a small change in 
`StaticTypeCheckingSupport#getDistance` can resolve the `map["$key"]` issues.  
I know Cedric stated in 6668 that this should be an STC error, but if there is 
just one method and it accepts String, it will be chosen for a GString 
argument.  This changes just closes the distance between GString and String so 
that `m(String)` is selected over `m(Object)`.
   
   https://issues.apache.org/jira/browse/GROOVY-6668
   https://issues.apache.org/jira/browse/GROOVY-8212




> 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