K2: add test for KT-57649

This commit is contained in:
Mikhail Glukhikh
2023-03-29 11:57:52 +02:00
committed by Space Team
parent 0dbf218f0b
commit 2e69c643cb
7 changed files with 46 additions and 0 deletions
@@ -16377,6 +16377,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
}
@Test
@TestMetadata("emptyIntersectionOnIf.kt")
public void testEmptyIntersectionOnIf() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/emptyIntersectionOnIf.kt");
}
@Test
@TestMetadata("kt45461.kt")
public void testKt45461() throws Exception {
@@ -16377,6 +16377,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
}
@Test
@TestMetadata("emptyIntersectionOnIf.kt")
public void testEmptyIntersectionOnIf() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/emptyIntersectionOnIf.kt");
}
@Test
@TestMetadata("kt45461.kt")
public void testKt45461() throws Exception {
@@ -16377,6 +16377,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
}
@Test
@TestMetadata("emptyIntersectionOnIf.kt")
public void testEmptyIntersectionOnIf() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/emptyIntersectionOnIf.kt");
}
@Test
@TestMetadata("kt45461.kt")
public void testKt45461() throws Exception {
@@ -16383,6 +16383,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
}
@Test
@TestMetadata("emptyIntersectionOnIf.kt")
public void testEmptyIntersectionOnIf() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/emptyIntersectionOnIf.kt");
}
@Test
@TestMetadata("kt45461.kt")
public void testKt45461() throws Exception {
@@ -0,0 +1,8 @@
// ISSUE: KT-57649
open class A
abstract class B {
fun test(current: A): A? =
// K2 reports empty intersection here due to the smart cast from A to B, where A & B aren't compatible
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING("K; B?, A?; multiple incompatible classes; : B, A")!>if (current === this) current else null<!>
}
@@ -0,0 +1,8 @@
// ISSUE: KT-57649
open class A
abstract class B {
fun test(current: A): A? =
// K2 reports empty intersection here due to the smart cast from A to B, where A & B aren't compatible
if (current === this) current else null
}
@@ -16383,6 +16383,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
}
@Test
@TestMetadata("emptyIntersectionOnIf.kt")
public void testEmptyIntersectionOnIf() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/emptyIntersectionOnIf.kt");
}
@Test
@TestMetadata("kt45461.kt")
public void testKt45461() throws Exception {