KT-4529 Lambdas are analyzed improperly in an infix call nested inside a println

#KT-4529 Fixed
This commit is contained in:
Svetlana Isakova
2014-02-11 16:15:28 +04:00
parent 2ebe8fd6a2
commit 70374ea9be
5 changed files with 47 additions and 5 deletions
@@ -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);
@@ -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<String>) {
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
@@ -7,9 +7,9 @@ fun composite() {
}
fun html() {
<!SYNTAX!><<!><!FUNCTION_CALL_EXPECTED!>html<!><!UNRESOLVED_REFERENCE!>><!><!SYNTAX!><<!><!DEBUG_INFO_MISSING_UNRESOLVED!>/<!><!FUNCTION_CALL_EXPECTED!>html<!><!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>><!><!SYNTAX!><!>
<!SYNTAX!><<!><!FUNCTION_CALL_EXPECTED!>html<!><!UNRESOLVED_REFERENCE!>><!><!SYNTAX!><<!><!DEBUG_INFO_MISSING_UNRESOLVED!>/<!><!DEBUG_INFO_MISSING_UNRESOLVED!>html<!><!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>><!><!SYNTAX!><!>
}
fun html1() {
<!SYNTAX!><<!><!FUNCTION_CALL_EXPECTED!>html<!><!UNRESOLVED_REFERENCE!>><!><!SYNTAX!><<!><!DEBUG_INFO_MISSING_UNRESOLVED!>/<!><!FUNCTION_CALL_EXPECTED!>html<!><!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>><!><!FUNCTION_CALL_EXPECTED!>html<!>
<!SYNTAX!><<!><!FUNCTION_CALL_EXPECTED!>html<!><!UNRESOLVED_REFERENCE!>><!><!SYNTAX!><<!><!DEBUG_INFO_MISSING_UNRESOLVED!>/<!><!DEBUG_INFO_MISSING_UNRESOLVED!>html<!><!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>><!><!FUNCTION_CALL_EXPECTED!>html<!>
}
@@ -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!!
<!DEBUG_INFO_AUTOCAST!>b<!>.bar()
}
@@ -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);
}