KT-2466 "When" on boolean produces VerifyError
#KT-2466 Fixed
This commit is contained in:
@@ -2855,7 +2855,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
boolean patternIsNullable = false;
|
boolean patternIsNullable = false;
|
||||||
JetType condJetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, condExpression);
|
JetType condJetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, condExpression);
|
||||||
Type condType;
|
Type condType;
|
||||||
if (isNumberPrimitive(subjectType)) {
|
if (isNumberPrimitive(subjectType) || subjectType.getSort() == Type.BOOLEAN) {
|
||||||
condType = asmType(condJetType);
|
condType = asmType(condJetType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun foo(b: Boolean) =
|
||||||
|
when (b) {
|
||||||
|
false -> 0
|
||||||
|
true -> 1
|
||||||
|
else -> 2
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String = if (foo(false) == 0 && foo(true) == 1) "OK" else "Fail"
|
||||||
|
|
||||||
@@ -158,4 +158,8 @@ public class PatternMatchingTest extends CodegenTestCase {
|
|||||||
public void testNullableWhen() throws Exception { // KT-2148
|
public void testNullableWhen() throws Exception { // KT-2148
|
||||||
blackBoxFile("patternMatching/nullableWhen.kt");
|
blackBoxFile("patternMatching/nullableWhen.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt2466() throws Exception {
|
||||||
|
blackBoxFile("patternMatching/kt2466.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user