Skip to content

Commit

Permalink
KT-35004: keep track of KotlinType for 'when' subject
Browse files Browse the repository at this point in the history
  • Loading branch information
dnpetrov committed Nov 22, 2019
1 parent ee4a5cc commit 89e0fc4
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5071,11 +5071,11 @@ else if (!isStatement) {
private StackValue generateWhenCondition(KtExpression subjectExpression, Type subjectType, KotlinType subjectKotlinType, int subjectLocal, KtWhenCondition condition) {
if (condition instanceof KtWhenConditionInRange) {
KtWhenConditionInRange conditionInRange = (KtWhenConditionInRange) condition;
return generateIn(StackValue.local(subjectLocal, subjectType),
return generateIn(StackValue.local(subjectLocal, subjectType, subjectKotlinType),
conditionInRange.getRangeExpression(),
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) {
KtWhenConditionIsPattern patternCondition = (KtWhenConditionIsPattern) condition;
return generateIsCheck(match, patternCondition.getTypeReference(), patternCondition.isNegated());
Expand Down
11 changes: 11 additions & 0 deletions compiler/testData/codegen/box/ranges/unsigned/kt35004.kt
Original file line number Diff line number Diff line change
@@ -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()

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 89e0fc4

Please sign in to comment.