Thodoris Sotiropoulos created GROOVY-11010: ----------------------------------------------
Summary: 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 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 (v8.20.10#820010)