diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 81baf9d1ca4..b0f80d65c05 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -1141,9 +1141,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { resolutionResults = OverloadResolutionResultsImpl.nameNotFound(); } - JetExpression right = binaryExpression.getRight(); - if (right != null) { - dataFlowInfo = facade.getTypeInfo(right, contextWithDataFlow).getDataFlowInfo(); + if (resolutionResults.isSingleResult()) { + dataFlowInfo = resolutionResults.getResultingCall().getDataFlowInfoForArguments().getResultInfo(); } return JetTypeInfo.create(OverloadResolutionResultsUtil.getResultingType(resolutionResults, context.contextDependency), dataFlowInfo); diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt4529.kt b/compiler/testData/diagnostics/tests/functionLiterals/kt4529.kt new file mode 100644 index 00000000000..517f4e427b8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt4529.kt @@ -0,0 +1,19 @@ +//KT-4529 Lambdas are analyzed improperly in an infix call nested inside a println + +class G { + fun foo(bar: (Int) -> Int) = bar +} + +fun main(args: Array) { + use( + G().foo {it + 11} // no error + ) + use( + G() foo {it + 11} // ERROR + ) + use( + G() foo ({it + 1}) // 2 ERRORs + ) +} + +fun use(a: Any?) = a \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/recovery/absentLeftHandSide.kt b/compiler/testData/diagnostics/tests/recovery/absentLeftHandSide.kt index 704445e3e07..2228fae7f4c 100644 --- a/compiler/testData/diagnostics/tests/recovery/absentLeftHandSide.kt +++ b/compiler/testData/diagnostics/tests/recovery/absentLeftHandSide.kt @@ -7,9 +7,9 @@ fun composite() { } fun html() { - <html></html> + <html></html> } fun html1() { - <html></html>html + <html></html>html } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt b/compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt new file mode 100644 index 00000000000..9e2a1ee7011 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt @@ -0,0 +1,14 @@ +package o + +class A { + fun foo(b: B) = b +} + +class B { + fun bar() {} +} + +fun test(a: A, b: B?) { + a foo b!! + b.bar() +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 0cf50df8e92..4e1d965816b 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -3086,6 +3086,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest("compiler/testData/diagnostics/tests/functionLiterals/kt2906.kt"); } + @TestMetadata("kt4529.kt") + public void testKt4529() throws Exception { + doTest("compiler/testData/diagnostics/tests/functionLiterals/kt4529.kt"); + } + @TestMetadata("LabeledFunctionLiterals.kt") public void testLabeledFunctionLiterals() throws Exception { doTest("compiler/testData/diagnostics/tests/functionLiterals/LabeledFunctionLiterals.kt"); @@ -6358,6 +6363,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { @TestMetadata("compiler/testData/diagnostics/tests/smartCasts") @InnerTestClasses({SmartCasts.Inference.class}) public static class SmartCasts extends AbstractJetDiagnosticsTest { + @TestMetadata("afterBinaryExpr.kt") + public void testAfterBinaryExpr() throws Exception { + doTest("compiler/testData/diagnostics/tests/smartCasts/afterBinaryExpr.kt"); + } + public void testAllFilesPresentInSmartCasts() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/smartCasts"), Pattern.compile("^(.+)\\.kt$"), true); }