new inference: proceed with additional constraints when no nested calls available (IDEA-124424)

This commit is contained in:
Anna Kozlova
2014-08-12 19:35:37 +04:00
parent 367b37d027
commit 4095b411aa
4 changed files with 16 additions and 2 deletions
@@ -221,7 +221,8 @@ public class InferenceSession {
return prepareSubstitution();
}
if (parameters != null && args != null && !MethodCandidateInfo.isOverloadCheck()) {
if (parameters != null && args != null &&
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(PsiUtil.skipParenthesizedExprUp(parent.getParent()))) {
final Set<ConstraintFormula> additionalConstraints = new LinkedHashSet<ConstraintFormula>();
if (parameters.length > 0) {
collectAdditionalConstraints(parameters, args, properties.getMethod(), PsiSubstitutor.EMPTY, additionalConstraints, properties.isVarargs(), true);
@@ -92,7 +92,7 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement
if (PsiUtil.isLanguageLevel8OrHigher(this) &&
PsiPolyExpressionUtil.isPolyExpression(this) &&
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(this.getParent())) {
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(PsiUtil.skipParenthesizedExprUp(this.getParent()))) {
//15.25.3 Reference Conditional Expressions
// The type of a poly reference conditional expression is the same as its target type.
return InferenceSession.getTargetType(this);
@@ -0,0 +1,12 @@
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
class Main {
void bar(final Stream<Object> objectStream) {
foo(objectStream.map(o -> "str").collect(toList()));
}
void foo(Iterable<?> k){}
void foo(String s){}
}
@@ -92,6 +92,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA124961() { doTest(); }
public void testIDEA126109() { doTest(); }
public void testIDEA126809() { doTest(); }
public void testIDEA124424() { doTest(); }
public void testIDEA127596() throws Exception {
doTest();