Commit 51d4e993 authored by Anna.Kozlova's avatar Anna.Kozlova
Browse files

static imports: don't compare with expected type when it depends on unresolved...

static imports: don't compare with expected type when it depends on unresolved reference (IDEA-163072)
parent c3a6faa9
Branches unavailable Tags unavailable
No related merge requests found
Showing with 43 additions and 5 deletions
+43 -5
......@@ -988,7 +988,7 @@ public class ExpectedTypesProvider {
final MethodCandidateInfo info = (MethodCandidateInfo)candidateInfo;
substitutor = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(argumentList, false,
() -> info.inferSubstitutorFromArgs(policy, args));
if (!info.isStaticsScopeCorrect() && !method.hasModifierProperty(PsiModifier.STATIC)) continue;
if (!info.isStaticsScopeCorrect() && !method.hasModifierProperty(PsiModifier.STATIC) || info.getInferenceErrorMessage() != null) continue;
}
else {
substitutor = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(argumentList, false, candidateInfo::getSubstitutor);
......
......@@ -184,8 +184,12 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
session.registerIncompatibleErrorMessage(message);
}
}
return null;
}
else {
session.registerIncompatibleErrorMessage("Failed to resolve argument");
return null;
}
return null;
}
return session;
}
......
......@@ -3,8 +3,8 @@ import java.util.*;
class Main {
void foo(List<Integer> list) {
bar(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
bar1(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
bar(list, <error descr="Failed to resolve argument">i -> i.intValue()</error>, i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
bar1(list, <error descr="Failed to resolve argument">i -> i.intValue()</error>, i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
}
<U, S_IN, S_OUT, R> R bar(List<S_IN> list,
......
......@@ -48,7 +48,7 @@ class Test2 {
{
Class c = D.class;
D<String> d = new D<>(s -> s.<error descr="Cannot resolve method 'isEmpty()'">isEmpty</error>(), c);
D<String> d = new D<error descr="Cannot infer arguments"><></error>(s -> s.<error descr="Cannot resolve method 'isEmpty()'">isEmpty</error>(), c);
D<String> d1 = D.create(s -> s.<error descr="Cannot resolve method 'isEmpty()'">isEmpty</error>(), c);
}
}
\ No newline at end of file
// "Import static method 'java.util.stream.Collectors.toList'" "true"
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
public class X {
{
System.out.println(Stream.of(123, 456)
.map(i -> i + 1)
.collect(toList()));
}
}
class Y {
private static void toList() {}
}
\ No newline at end of file
// "Import static method 'java.util.stream.Collectors.toList'" "true"
import java.util.stream.Stream;
public class X {
{
System.out.println(Stream.of(123, 456)
.map(i -> i + 1)
.collect(toLi<caret>st()));
}
}
class Y {
private static void toList() {}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment