Details
-
Bug
-
Status: Reopened
-
Major
-
Resolution: Unresolved
-
4.0.4
-
None
-
None
Description
This appears to be similar to GROOVY-9881, but it's specifically in the method-overload procedure. Given a functional value type with two method overloads:
interface Try<T> { Try<T> andThenTry(Consumer<? super T>) Try<T> andThenTry(Runnable) }
When this code is invoked from static code, the STC errors out on an ambiguous method reference even if the method type isn't:
// AWS SDK 2 DynamoDbTable class DynamoDbTable { void putItem(PutItemRequest<T>) void putItem(Consumer<PutItemRequest.Builder<T>) void putItem(T) } @CompileStatic class MyServiceClass { void doThing() { Try.success(putItemRequest()) .andThenTry(table::putItem) // T for Try<T> is PutItemRequest<I> } }
produces
[Static type checking] - Reference to method is ambiguous. Cannot choose between [Try<T> Try#andThenTry(Consumer<? super T>), Try<T> Try#andThenTry(Runnable)]
I think this may have something to do with the relaxed SAM matching that is used to bridge ambiguous closure syntax, but when a plain method reference is used, there's no ambiguity available.
Attachments
Issue Links
- is duplicated by
-
GROOVY-11129 STC chooses to call a non-polymorphic method although explicit type arguments are given
- Closed
- is related to
-
GROOVY-6189 basic SAM conversion
- Closed
-
GROOVY-9852 Result is already complete (IllegalStateException)
- Closed
-
GROOVY-9881 STC can't distinguish SAMs based on arity
- Closed
- relates to
-
GROOVY-11010 Ambiguous method reference when expecting a SAM type
- Open
-
GROOVY-10963 AIOOBE with Java lambda syntax
- Closed