KT-2466 "When" on boolean produces VerifyError

#KT-2466 Fixed
This commit is contained in:
Alexander Udalov
2012-07-19 21:12:58 +04:00
parent 98efc0276a
commit db008d5d38
3 changed files with 14 additions and 1 deletions
@@ -2855,7 +2855,7 @@ The "returned" value of try expression with no finally is either the last expres
boolean patternIsNullable = false;
JetType condJetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, condExpression);
Type condType;
if (isNumberPrimitive(subjectType)) {
if (isNumberPrimitive(subjectType) || subjectType.getSort() == Type.BOOLEAN) {
condType = asmType(condJetType);
}
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
blackBoxFile("patternMatching/nullableWhen.kt");
}
public void testKt2466() throws Exception {
blackBoxFile("patternMatching/kt2466.kt");
}
}