Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
I have the following program
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; } }
Actual behavior
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
Expected behavior
Compile successfully
Notes
Tested against master (commit: 5bcd83e0fde722971f97d479f1a4d6da6cd4aa5f)
Test case adapted from (Guava library)
import java.util.function.*; class Main { static final void test() { com.google.common.cache.CacheLoader.from(Main::m); } }
Attachments
Issue Links
- is related to
-
GROOVY-10714 STC: Callable, Runnable, Serializable overload preference for functional argument (closure, lambda, etc.)
- Reopened
-
GROOVY-7582 Closure to SAM coercion doesn't handle overloads with different SAM signatures
- Closed
-
GROOVY-9852 Result is already complete (IllegalStateException)
- Closed
-
GROOVY-9881 STC can't distinguish SAMs based on arity
- Closed
-
GROOVY-10905 Improve matching implicit arg closures to SAM types
- Closed