K2: Avoid false-positive overload resolution ambiguity with smart casts

The idea is that when we have successful candidates both from smart cast
and original type, we should discriminate in the favor of former ones.

While this problem (see kt55722.kt) existed before this branch is merged,
initially it was recognized on FP Ultimate when we stopped assuming
captured types from the same projections as equal (see kt55722Initial.kt).

^KT-55722 Fixed
^KT-55024 Fixed
^KT-56283 Related
^KT-56310 Related
This commit is contained in:
Denis.Zharkov
2023-01-02 12:00:14 +01:00
committed by Space Team
parent 7b6c6fceb6
commit b6b132a9a3
27 changed files with 1034 additions and 35 deletions
@@ -27371,6 +27371,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt37692.kt");
}
@Test
@TestMetadata("kt55722.kt")
public void testKt55722() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt55722.kt");
}
@Test
@TestMetadata("kt55722Initial.kt")
public void testKt55722Initial() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt55722Initial.kt");
}
@Test
@TestMetadata("numberOfDefaults.kt")
public void testNumberOfDefaults() throws Exception {
@@ -34694,12 +34706,30 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/visibility/javaInterfaceFieldDirectAccess.kt");
}
@Test
@TestMetadata("kt56283.kt")
public void testKt56283() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/kt56283.kt");
}
@Test
@TestMetadata("lackOfInvisibleSetterOfJavaClassInSamePackage.kt")
public void testLackOfInvisibleSetterOfJavaClassInSamePackage() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/lackOfInvisibleSetterOfJavaClassInSamePackage.kt");
}
@Test
@TestMetadata("moreSpecificProtected.kt")
public void testMoreSpecificProtected() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/moreSpecificProtected.kt");
}
@Test
@TestMetadata("moreSpecificProtectedSimple.kt")
public void testMoreSpecificProtectedSimple() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/moreSpecificProtectedSimple.kt");
}
@Test
@TestMetadata("notOverridingInternal.kt")
public void testNotOverridingInternal() throws Exception {
@@ -34801,6 +34831,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
public void testProtectedVisibilityAndSmartcast_overrideSameType() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/protectedVisibilityAndSmartcast_overrideSameType.kt");
}
@Test
@TestMetadata("smartCastAndSuppressedVisibility.kt")
public void testSmartCastAndSuppressedVisibility() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/smartCastAndSuppressedVisibility.kt");
}
}
@Nested