You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KeyedStream.stream(elements)
.flatMap(this::getValues)
// where there are two overloaded
private Stream<Value> getValues(Key key);
private Stream<Value> getValues(Key key, Object o2);
ERROR: reference to flatMap is ambiguous
.flatMap(this::getValues)
^
both method <R#1>flatMap(Function<? super V,? extends Stream<? extends R#1>>) in KeyedStream and method <R#2>flatMap(BiFunction<? super K,? super V,? extends Stream<? extends R#2>>) in KeyedStream match
where R#1,V,K,R#2 are type-variables:
R#1 extends Object declared in method <R#1>flatMap(Function<? super V,? extends Stream<? extends R#1>>)
V extends Object declared in interface KeyedStream
K extends Object declared in interface KeyedStream
R#2 extends Object declared in method <R#2>flatMap(BiFunction<? super K,? super V,? extends Stream<? extends R#2>>)
Example LambdaMethodReferenceTest test case reproducing case.
Skip the automated refactor as the lambda is simpler, or refactor to valid code that is not an ambiguous method reference such as the following with explicit cast (though stylistically in this case the lambda is shorter and clearer).
Note that this uses the expensive `SuggestedFixes.compilesWithFix`
check which can result in poor performance, particularly on large
projects.
Fortunately this case isn't very common (no occurrences in a
very large internal project).
Note that this uses the expensive `SuggestedFixes.compilesWithFix`
check which can result in poor performance, particularly on large
projects.
Fortunately this case isn't very common (no occurrences in a
very large internal project).
What happened?
After upgrading gradle-baseline, the automated LambdaMethodReference refactoring triggered a compilation error on a project due to ambiguous method reference for a
KeyedStream#flatMap
which has two overloads -- one taking aFunction<? super V, ? extends Stream<? extends R>> mapper
and the other taking aBiFunction<? super K, ? super V, ? extends Stream<? extends R>> entryMapper
Before refactoring:
After refactoring, fails compilation:
Example
LambdaMethodReferenceTest
test case reproducing case.What did you want to happen?
Skip the automated refactor as the lambda is simpler, or refactor to valid code that is not an ambiguous method reference such as the following with explicit cast (though stylistically in this case the lambda is shorter and clearer).
The text was updated successfully, but these errors were encountered: