Substitute captured types with inner intersection one (NewTypeSubstitutor)

^KT-44651 Fixed
This commit is contained in:
Victor Petukhov
2021-02-09 12:58:53 +03:00
parent 80daf120e6
commit f797ee7803
6 changed files with 39 additions and 1 deletions
@@ -16666,6 +16666,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
}
@Test
@TestMetadata("substituteIntersectionTypeInsideCapType.kt")
public void testSubstituteIntersectionTypeInsideCapType() throws Exception {
runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt");
}
@Test
@TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt")
public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception {
@@ -105,7 +105,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
val substitutedInnerType = substitute(innerType, keepAnnotation, runCapturedChecks = false)
if (substitutedInnerType != null) {
if (innerType is StubType || substitutedInnerType is StubType) {
if (innerType is StubType || substitutedInnerType is StubType || innerType.constructor is IntersectionTypeConstructor) {
return NewCapturedType(
capturedType.captureStatus,
NewCapturedTypeConstructor(
@@ -0,0 +1,15 @@
// TARGET_BACKEND: JVM
// TARGET_BACKEND: JVM_IR
class X<T: Number>(val y: Any, val x: T)
fun box(): String {
val num: Long = -10
val num2: Int = 20
val obj = if (true)
X(Any(), if (true) num else num2)
else
X(Any(), -25)
val f = obj.y
return "OK"
}
@@ -16666,6 +16666,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
}
@Test
@TestMetadata("substituteIntersectionTypeInsideCapType.kt")
public void testSubstituteIntersectionTypeInsideCapType() throws Exception {
runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt");
}
@Test
@TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt")
public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception {
@@ -16666,6 +16666,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
}
@Test
@TestMetadata("substituteIntersectionTypeInsideCapType.kt")
public void testSubstituteIntersectionTypeInsideCapType() throws Exception {
runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt");
}
@Test
@TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt")
public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception {
@@ -13855,6 +13855,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt");
}
@TestMetadata("substituteIntersectionTypeInsideCapType.kt")
public void testSubstituteIntersectionTypeInsideCapType() throws Exception {
runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt");
}
@TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt")
public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception {
runTest("compiler/testData/codegen/box/inference/subtypingOfIntersectionIltInsideFlexible.kt");