Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
Description
I have the following program
import java.util.function.*; class Foo<T> { static <T> Foo<T> of(Iterable<T> values) { return null; } static <T> Foo<T> of(T values) { return null; } } class Main { static final void test() { Foo.<IntUnaryOperator>of((int s) -> s + 1); } }
Actual behavior
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 10: [Static type checking] - Wrong number of parameters for method target: iterator() @ line 10, column 38. var x = Foo.<IntUnaryOperator>of((int s) -> s + 1); ^ 1 error
Expected behavior
Compile successfully
Notes
Test case adapted from the following program that uses the apache-commons-io library:
import org.apache.commons.io.function.*; import java.util.function.*; class Main { static final void test() { var x = IOStream.<IntUnaryOperator>of((int s) -> s + 1); } }
Attachments
Issue Links
- is related to
-
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