no 'dangling function literal' check for nested calls
This commit is contained in:
@@ -477,7 +477,8 @@ public class CallResolver {
|
||||
// }
|
||||
ImmutableSet<OverloadResolutionResults.Code> someFailed = ImmutableSet.of(OverloadResolutionResults.Code.MANY_FAILED_CANDIDATES,
|
||||
OverloadResolutionResults.Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH);
|
||||
if (someFailed.contains(results.getResultCode()) && !task.call.getFunctionLiteralArguments().isEmpty()) {
|
||||
if (someFailed.contains(results.getResultCode()) && !task.call.getFunctionLiteralArguments().isEmpty()
|
||||
&& task.resolveMode == ResolveMode.TOP_LEVEL_CALL) { //For nested calls there are no such cases
|
||||
// We have some candidates that failed for some reason
|
||||
// And we have a suspect: the function literal argument
|
||||
// Now, we try to remove this argument and see if it helps
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package baz
|
||||
|
||||
fun test() {
|
||||
<!NONE_APPLICABLE!>foo<!>(1) <!DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED!>{}<!>
|
||||
|
||||
foo( <!NONE_APPLICABLE!>foo<!>(1) {} ) //here
|
||||
}
|
||||
|
||||
fun foo(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
||||
|
||||
fun foo() : (i : () -> Unit) -> Unit = {}
|
||||
@@ -169,11 +169,6 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/CyclicHierarchy.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("DanglingFunctionLiteral.kt")
|
||||
public void testDanglingFunctionLiteral() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/DanglingFunctionLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("DefaultValuesTypechecking.kt")
|
||||
public void testDefaultValuesTypechecking() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt");
|
||||
@@ -2300,6 +2295,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/functionLiterals"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("DanglingFunctionLiteral.kt")
|
||||
public void testDanglingFunctionLiteral() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/functionLiterals/DanglingFunctionLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ExpectedParameterTypeMismatchVariance.kt")
|
||||
public void testExpectedParameterTypeMismatchVariance() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/functionLiterals/ExpectedParameterTypeMismatchVariance.kt");
|
||||
@@ -2315,6 +2315,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/functionLiterals/kt2906.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoDanglingFunctionLiteralForNestedCalls.kt")
|
||||
public void testNoDanglingFunctionLiteralForNestedCalls() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/functionLiterals/NoDanglingFunctionLiteralForNestedCalls.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unusedLiteral.kt")
|
||||
public void testUnusedLiteral() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt");
|
||||
|
||||
Reference in New Issue
Block a user