K2: expand types during smartcasting to prevent redundant intersections
#KT-53184 Fixed
This commit is contained in:
+6
@@ -17829,6 +17829,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("getOnNullableTypeAlias.kt")
|
||||
public void testGetOnNullableTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/getOnNullableTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitNothingInDelegate.kt")
|
||||
public void testImplicitNothingInDelegate() throws Exception {
|
||||
|
||||
Generated
+6
@@ -2632,6 +2632,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectGetOnNullableTypeAlias.kt")
|
||||
public void testReflectGetOnNullableTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SafeLetWithReturn.kt")
|
||||
public void testSafeLetWithReturn() throws Exception {
|
||||
|
||||
+6
@@ -2632,6 +2632,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex
|
||||
runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectGetOnNullableTypeAlias.kt")
|
||||
public void testReflectGetOnNullableTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SafeLetWithReturn.kt")
|
||||
public void testSafeLetWithReturn() throws Exception {
|
||||
|
||||
@@ -361,10 +361,10 @@ private inline fun <T : FirExpression> BodyResolveComponents.transformExpression
|
||||
SmartcastStability.STABLE_VALUE
|
||||
}
|
||||
|
||||
val originalType = expression.resultType.coneType
|
||||
val originalType = expression.resultType.coneType.fullyExpandedType(session)
|
||||
val allTypes = typesFromSmartCast.also {
|
||||
if (originalType !is ConeStubType) {
|
||||
it += originalType
|
||||
it += originalType.fullyExpandedType(session)
|
||||
}
|
||||
}
|
||||
if (allTypes.all { it is ConeDynamicType }) return null
|
||||
|
||||
Reference in New Issue
Block a user