[FIR] When call candidates resolve to errors, select the least bad ones

This fixes a scenario when INVISIBLE_REFERENCE is suppressed, but we
resolved to the wrong overload because when none of the candidates were
applicable, more or less the first one was chosen.

Because we call `fullyProcessCandidate` on the candidates, their
applicability can change which can lead to a situation where the
applicability of a ConeAmbiguityError is different to all its
candidates. The changes in coneDiagnosticToFirDiagnostic.kt account for
that, otherwise code like candidates.first { it.applicability ==
CandidateApplicability.UNSAFE_CALL } can throw NoSuchElementException.

#KT-57776 Fixed
This commit is contained in:
Kirill Rakhman
2023-04-05 17:21:24 +02:00
committed by Space Team
parent 09ea0ef757
commit 592baee852
24 changed files with 345 additions and 52 deletions
@@ -39966,6 +39966,26 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suppressions")
@TestDataPath("$PROJECT_ROOT")
@Tag("codegenK2")
@Tag("firCodegen")
@UseExtTestCaseGroupProvider()
@FirPipeline()
public class Suppressions {
@Test
public void testAllFilesPresentInSuppressions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("suppressInvisible.kt")
public void testSuppressInvisible() throws Exception {
runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suspendConversion")
@TestDataPath("$PROJECT_ROOT")
@@ -40948,6 +40948,28 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suppressions")
@TestDataPath("$PROJECT_ROOT")
@Tag("codegenK2")
@Tag("firCodegen")
@UseExtTestCaseGroupProvider()
@FirPipeline()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class Suppressions {
@Test
public void testAllFilesPresentInSuppressions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("suppressInvisible.kt")
public void testSuppressInvisible() throws Exception {
runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suspendConversion")
@TestDataPath("$PROJECT_ROOT")
@@ -39475,6 +39475,25 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suppressions")
@TestDataPath("$PROJECT_ROOT")
@Tag("codegen")
@Tag("k1Codegen")
@UseExtTestCaseGroupProvider()
public class Suppressions {
@Test
public void testAllFilesPresentInSuppressions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("suppressInvisible.kt")
public void testSuppressInvisible() throws Exception {
runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suspendConversion")
@TestDataPath("$PROJECT_ROOT")
@@ -40457,6 +40457,27 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suppressions")
@TestDataPath("$PROJECT_ROOT")
@Tag("codegen")
@Tag("k1Codegen")
@UseExtTestCaseGroupProvider()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class Suppressions {
@Test
public void testAllFilesPresentInSuppressions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("suppressInvisible.kt")
public void testSuppressInvisible() throws Exception {
runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/suspendConversion")
@TestDataPath("$PROJECT_ROOT")