#EA-79158 Fix translation of empty 'when' statement

This commit is contained in:
Alexey Andreev
2016-02-17 13:58:12 +03:00
parent 133402c1ca
commit 8497931455
3 changed files with 12 additions and 2 deletions
@@ -133,4 +133,8 @@ public final class WhenTest extends AbstractExpressionTest {
public void testWhenStatementWithRangeClause() throws Exception {
checkFooBoxIsOk();
}
public void testEmpty() throws Exception {
checkFooBoxIsOk();
}
}
@@ -67,7 +67,7 @@ public final class WhenTranslator extends AbstractTranslator {
}
}
private JsStatement translate() {
private JsNode translate() {
if (expressionToMatch != null && JsAstUtils.isEmptyExpression(expressionToMatch)) {
return JsEmpty.INSTANCE;
}
@@ -100,7 +100,7 @@ public final class WhenTranslator extends AbstractTranslator {
currentIf = nextIf;
}
}
return resultIf;
return resultIf != null ? resultIf : context().getEmptyExpression();
}
@NotNull
@@ -0,0 +1,6 @@
package foo
fun box(): String {
when {}
return "OK"
}