[FIR] Fix CAST_NEVER_SUCCEEDS for definitely not null types
This commit is contained in:
committed by
Space Team
parent
0efcad51e9
commit
df43226a08
+6
@@ -5767,6 +5767,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("DefinitelyNotNullTypes.kt")
|
||||||
|
public void testDefinitelyNotNullTypes() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/DefinitelyNotNullTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("MappedDirect.kt")
|
@TestMetadata("MappedDirect.kt")
|
||||||
public void testMappedDirect() throws Exception {
|
public void testMappedDirect() throws Exception {
|
||||||
|
|||||||
+6
@@ -5767,6 +5767,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("DefinitelyNotNullTypes.kt")
|
||||||
|
public void testDefinitelyNotNullTypes() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/DefinitelyNotNullTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("MappedDirect.kt")
|
@TestMetadata("MappedDirect.kt")
|
||||||
public void testMappedDirect() throws Exception {
|
public void testMappedDirect() throws Exception {
|
||||||
|
|||||||
+6
@@ -5761,6 +5761,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("DefinitelyNotNullTypes.kt")
|
||||||
|
public void testDefinitelyNotNullTypes() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/DefinitelyNotNullTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("MappedDirect.kt")
|
@TestMetadata("MappedDirect.kt")
|
||||||
public void testMappedDirect() throws Exception {
|
public void testMappedDirect() throws Exception {
|
||||||
|
|||||||
+6
@@ -5767,6 +5767,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("DefinitelyNotNullTypes.kt")
|
||||||
|
public void testDefinitelyNotNullTypes() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/DefinitelyNotNullTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("MappedDirect.kt")
|
@TestMetadata("MappedDirect.kt")
|
||||||
public void testMappedDirect() throws Exception {
|
public void testMappedDirect() throws Exception {
|
||||||
|
|||||||
+2
-2
@@ -32,8 +32,8 @@ fun checkCasting(
|
|||||||
isSafeCase: Boolean,
|
isSafeCase: Boolean,
|
||||||
context: CheckerContext
|
context: CheckerContext
|
||||||
): CastingType {
|
): CastingType {
|
||||||
val lhsLowerType = lhsType.lowerBoundIfFlexible()
|
val lhsLowerType = lhsType.lowerBoundIfFlexible().originalIfDefinitelyNotNullable()
|
||||||
val rhsLowerType = rhsType.lowerBoundIfFlexible()
|
val rhsLowerType = rhsType.lowerBoundIfFlexible().originalIfDefinitelyNotNullable()
|
||||||
|
|
||||||
if (lhsLowerType is ConeErrorType || rhsLowerType is ConeErrorType) return CastingType.Possible
|
if (lhsLowerType is ConeErrorType || rhsLowerType is ConeErrorType) return CastingType.Possible
|
||||||
|
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
|
fun <T, K> test(x: T & Any) {
|
||||||
|
x <!USELESS_CAST!>as (T & Any)<!>
|
||||||
|
x <!UNCHECKED_CAST!>as (K & Any)<!>
|
||||||
|
}
|
||||||
Generated
+6
@@ -5767,6 +5767,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/CastToNotNullSuper.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("DefinitelyNotNullTypes.kt")
|
||||||
|
public void testDefinitelyNotNullTypes() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/cast/neverSucceeds/DefinitelyNotNullTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("MappedDirect.kt")
|
@TestMetadata("MappedDirect.kt")
|
||||||
public void testMappedDirect() throws Exception {
|
public void testMappedDirect() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user