[FIR] Handle ConeIntersectionType in createSimpleType
^KT-62819 Fixed
This commit is contained in:
committed by
Space Team
parent
11586975e8
commit
3188f01720
+6
@@ -15912,6 +15912,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
|
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
|
@Test
|
||||||
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
||||||
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
||||||
|
|||||||
+6
@@ -15912,6 +15912,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
|
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
|
@Test
|
||||||
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
||||||
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
||||||
|
|||||||
+6
@@ -15906,6 +15906,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
|
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
|
@Test
|
||||||
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
||||||
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
||||||
|
|||||||
+6
@@ -15912,6 +15912,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
|
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
|
@Test
|
||||||
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
||||||
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
||||||
|
|||||||
@@ -95,9 +95,16 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
nullable,
|
nullable,
|
||||||
coneAttributes
|
coneAttributes
|
||||||
)
|
)
|
||||||
|
is ConeIntersectionType -> if (coneAttributes === constructor.attributes) {
|
||||||
|
constructor
|
||||||
|
} else {
|
||||||
|
ConeIntersectionType(
|
||||||
|
constructor.intersectedTypes.map { it.withAttributes(coneAttributes) },
|
||||||
|
constructor.alternativeType?.withAttributes(coneAttributes)
|
||||||
|
)
|
||||||
|
}
|
||||||
else -> error("!")
|
else -> error("!")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createTypeArgument(type: KotlinTypeMarker, variance: TypeVariance): TypeArgumentMarker {
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+6
@@ -15912,6 +15912,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/intersectionTypeMultipleBoundsAsReceiver.kt");
|
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
|
@Test
|
||||||
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
@TestMetadata("intersectionTypesWithContravariantTypes.kt")
|
||||||
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
public void testIntersectionTypesWithContravariantTypes() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user