[FIR] Handle ConeIntersectionType in createSimpleType

^KT-62819 Fixed
This commit is contained in:
Ivan Kochurkin
2023-11-02 21:09:39 +01:00
committed by Space Team
parent 11586975e8
commit 3188f01720
7 changed files with 54 additions and 1 deletions
@@ -15912,6 +15912,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
}
@Test
@TestMetadata("intersectionTypeOnWhenCall.kt")
public void testIntersectionTypeOnWhenCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeOnWhenCall.kt");
}
@Test
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
public void testIntersectionTypesWithContravariantTypes() throws Exception {
@@ -15912,6 +15912,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
}
@Test
@TestMetadata("intersectionTypeOnWhenCall.kt")
public void testIntersectionTypeOnWhenCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeOnWhenCall.kt");
}
@Test
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
public void testIntersectionTypesWithContravariantTypes() throws Exception {
@@ -15906,6 +15906,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
}
@Test
@TestMetadata("intersectionTypeOnWhenCall.kt")
public void testIntersectionTypeOnWhenCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeOnWhenCall.kt");
}
@Test
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
public void testIntersectionTypesWithContravariantTypes() throws Exception {
@@ -15912,6 +15912,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
}
@Test
@TestMetadata("intersectionTypeOnWhenCall.kt")
public void testIntersectionTypeOnWhenCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeOnWhenCall.kt");
}
@Test
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
public void testIntersectionTypesWithContravariantTypes() throws Exception {
@@ -95,9 +95,16 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
nullable,
coneAttributes
)
is ConeIntersectionType -> if (coneAttributes === constructor.attributes) {
constructor
} else {
ConeIntersectionType(
constructor.intersectedTypes.map { it.withAttributes(coneAttributes) },
constructor.alternativeType?.withAttributes(coneAttributes)
)
}
else -> error("!")
}
}
override fun createTypeArgument(type: KotlinTypeMarker, variance: TypeVariance): TypeArgumentMarker {
@@ -0,0 +1,16 @@
// FIR_IDENTICAL
// ISSUE: KT-62819
class A<T>
fun foo(cond: Boolean) {
val first = when (cond) {
true -> A<Int>()
false -> A<String?>()
}
val second = when (cond) {
true -> first
false -> first
}
}
@@ -15912,6 +15912,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
}
@Test
@TestMetadata("intersectionTypeOnWhenCall.kt")
public void testIntersectionTypeOnWhenCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeOnWhenCall.kt");
}
@Test
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
public void testIntersectionTypesWithContravariantTypes() throws Exception {