gradle-baseline
gradle-baseline copied to clipboard
Rewriting lambdas to method references can produce ambiguous code that doesn't compile
What happened?
If a method has two overloads, one for Function
and one for BiFunction
, it's possible for the rule to rewrite lambdas to produce ambiguous code. x -> y.get(x)
is unambiguous, but y::get
may be ambiguous if there are multiple variants of get
.
What did you want to happen?
It shouldn't rewrite those lambdas, or rewriting them should include the cast required to make it unambiguous.
The issue is actually with the receiver of the lambda being overloaded, not with the lambda itself. We could verify that there isn't an overload to avoid the problem. In practice I've only seen this with KeyedStream
which in generally deprecated in favour of EntryStream