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

Christopher Smith commented on GROOVY-11010:
--------------------------------------------

Thank you for this update, Paul! I strongly advocate for the Java-style "prefer 
a return value" rule, most especially because of functional pipelines; Groovy's 
coercing void to null can sometimes result in silently broken pipes, and if 
information exists, it seems strange for the default behavior to be to discard 
it instead of preserve it. Is that decision in scope for _this ticket_ and just 
not the PR, or does the discussion go somewhere else?

> Ambiguous method reference when expecting a SAM type
> ----------------------------------------------------
>
>                 Key: GROOVY-11010
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11010
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Minor
>
> I have the following program
> {code}
> import java.util.function.*;
> class Main {
>   static final void test() {
>     from(Main::m);
>   }
>   static <K, V> void from(Function<K, V> f) {}
>   static <V> void from(Supplier<V> f) {}
>   static int m(String x) { return 1; }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 6: [Static type checking] - Reference to method is ambiguous. 
> Cannot choose between [void Main#from(java.util.function.Supplier<V>), void 
> Main#from(java.util.function.Function<K, V>)]
>  @ line 6, column 5.
>        from(Main::m);
>        ^
> 1 error
> {code}
> h3. Expected behavior 
> Compile successfully
> h3. Notes
> Tested against master (commit: 5bcd83e0fde722971f97d479f1a4d6da6cd4aa5f)
> Test case adapted from (Guava library)
> {code}
> import java.util.function.*;
> class Main {
>   static final void test() {
>     com.google.common.cache.CacheLoader.from(Main::m);
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to