Exhaustive when with 'Unit' result now also generates an exception in else branch #KT-12192 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-05-16 18:14:33 +03:00
parent 23a4184e48
commit f35fd32a25
5 changed files with 42 additions and 6 deletions
@@ -4044,12 +4044,9 @@ The "returned" value of try expression with no finally is either the last expres
}
private boolean isExhaustive(@NotNull KtWhenExpression whenExpression, boolean isStatement) {
if (isStatement) {
return Boolean.TRUE.equals(bindingContext.get(BindingContext.IMPLICIT_EXHAUSTIVE_WHEN, whenExpression));
}
else {
return Boolean.TRUE.equals(bindingContext.get(BindingContext.EXHAUSTIVE_WHEN, whenExpression));
}
boolean exhaustive = Boolean.TRUE.equals(bindingContext.get(BindingContext.EXHAUSTIVE_WHEN, whenExpression));
return isStatement ? exhaustive || Boolean.TRUE.equals(bindingContext.get(BindingContext.IMPLICIT_EXHAUSTIVE_WHEN, whenExpression))
: exhaustive;
}
public void putUnitInstanceOntoStackForNonExhaustiveWhen(