mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
lambda: check lambda return type compatibility before more specific checks (IDEA-97870)
This commit is contained in:
+3
-3
@@ -81,15 +81,15 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
// then noone can be more specific
|
||||
if (!atLeastOneMatch) return null;
|
||||
|
||||
checkLambdaApplicable(conflicts);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
checkSpecifics(conflicts, applicabilityLevel);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
checkPrimitiveVarargs(conflicts, myActualParameterTypes.length);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
checkLambdaApplicable(conflicts);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
THashSet<CandidateInfo> uniques = new THashSet<CandidateInfo>(conflicts);
|
||||
if (uniques.size() == 1) return uniques.iterator().next();
|
||||
return null;
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
class X {
|
||||
public static void main(final Stream<String> stream) throws Throwable {
|
||||
stream.map(s -> s.substring("http://".length())).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
interface Stream<T> {
|
||||
<R> Stream<R> map(Function<? super T, ? extends R> mapper);
|
||||
IntStream map(IntFunction<? super T> mapper);
|
||||
void forEach(Block<? super T> block);
|
||||
}
|
||||
|
||||
interface IntFunction<T> extends Function<T, Integer> {
|
||||
public int applyAsInt(T t);
|
||||
}
|
||||
|
||||
interface Function<T, R> {
|
||||
public R apply(T t);
|
||||
}
|
||||
|
||||
interface IntStream extends BaseStream<Integer> {}
|
||||
interface BaseStream<T> {}
|
||||
interface Block<T> {
|
||||
public void accept(T t);
|
||||
}
|
||||
+4
@@ -173,6 +173,10 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnTypeCompatibilityBeforeSpecificsCheck() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user