KT-35004: keep track of KotlinType for 'when' subject
This commit is contained in:
@@ -5071,11 +5071,11 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
private StackValue generateWhenCondition(KtExpression subjectExpression, Type subjectType, KotlinType subjectKotlinType, int subjectLocal, KtWhenCondition condition) {
|
private StackValue generateWhenCondition(KtExpression subjectExpression, Type subjectType, KotlinType subjectKotlinType, int subjectLocal, KtWhenCondition condition) {
|
||||||
if (condition instanceof KtWhenConditionInRange) {
|
if (condition instanceof KtWhenConditionInRange) {
|
||||||
KtWhenConditionInRange conditionInRange = (KtWhenConditionInRange) condition;
|
KtWhenConditionInRange conditionInRange = (KtWhenConditionInRange) condition;
|
||||||
return generateIn(StackValue.local(subjectLocal, subjectType),
|
return generateIn(StackValue.local(subjectLocal, subjectType, subjectKotlinType),
|
||||||
conditionInRange.getRangeExpression(),
|
conditionInRange.getRangeExpression(),
|
||||||
conditionInRange.getOperationReference());
|
conditionInRange.getOperationReference());
|
||||||
}
|
}
|
||||||
StackValue.Local match = subjectLocal == -1 ? null : StackValue.local(subjectLocal, subjectType);
|
StackValue.Local match = subjectLocal == -1 ? null : StackValue.local(subjectLocal, subjectType, subjectKotlinType);
|
||||||
if (condition instanceof KtWhenConditionIsPattern) {
|
if (condition instanceof KtWhenConditionIsPattern) {
|
||||||
KtWhenConditionIsPattern patternCondition = (KtWhenConditionIsPattern) condition;
|
KtWhenConditionIsPattern patternCondition = (KtWhenConditionIsPattern) condition;
|
||||||
return generateIsCheck(match, patternCondition.getTypeReference(), patternCondition.isNegated());
|
return generateIsCheck(match, patternCondition.getTypeReference(), patternCondition.isNegated());
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// KJS_WITH_FULL_RUNTIME
|
||||||
|
|
||||||
|
fun ULong.foobar() =
|
||||||
|
when (this) {
|
||||||
|
in 0U..1U -> "OK"
|
||||||
|
else -> throw AssertionError("$this")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String = 0UL.foobar()
|
||||||
+5
@@ -21998,6 +21998,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35004.kt")
|
||||||
|
public void testKt35004() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt35004.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+5
@@ -20815,6 +20815,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35004.kt")
|
||||||
|
public void testKt35004() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt35004.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+5
@@ -20533,6 +20533,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35004.kt")
|
||||||
|
public void testKt35004() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt35004.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+5
@@ -20533,6 +20533,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35004.kt")
|
||||||
|
public void testKt35004() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt35004.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
+5
@@ -17683,6 +17683,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35004.kt")
|
||||||
|
public void testKt35004() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt35004.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+5
@@ -18813,6 +18813,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/inMixedUnsignedRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35004.kt")
|
||||||
|
public void testKt35004() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt35004.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user