Delay check for possibly deferred return type for reference candidate

This issue appeared after recently added new overload for flatMapTo.
 Before that, we picked candidate returning List<T> and completed
 inference, now we also check one more flatMapTo, which is here is
 incorrect and as a result we go into outer scope. Outer scope contains
 one property with deferred type, which introduced error about
 "typechecker has run into recursive problem" even it isn't applicable
 by receiver.

 So, the fix is to check receiver first and only then check return
 type of a candidate.

 #KT-39470 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-06-09 13:44:15 +03:00
parent 21f7cd5d8f
commit 93e9d3e57d
6 changed files with 61 additions and 8 deletions
@@ -2850,6 +2850,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
runTest("compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.kt");
}
@TestMetadata("referenceWithTheSameNameAsContainingProperty.kt")
public void testReferenceWithTheSameNameAsContainingProperty() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/factoryPattern/referenceWithTheSameNameAsContainingProperty.kt");
}
@TestMetadata("resolutionInOldInference.kt")
public void testResolutionInOldInference() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/factoryPattern/resolutionInOldInference.kt");
@@ -2850,6 +2850,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
runTest("compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.kt");
}
@TestMetadata("referenceWithTheSameNameAsContainingProperty.kt")
public void testReferenceWithTheSameNameAsContainingProperty() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/factoryPattern/referenceWithTheSameNameAsContainingProperty.kt");
}
@TestMetadata("resolutionInOldInference.kt")
public void testResolutionInOldInference() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/factoryPattern/resolutionInOldInference.kt");