#EA-79158 Fix translation of empty 'when' statement
This commit is contained in:
@@ -133,4 +133,8 @@ public final class WhenTest extends AbstractExpressionTest {
|
|||||||
public void testWhenStatementWithRangeClause() throws Exception {
|
public void testWhenStatementWithRangeClause() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testEmpty() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -67,7 +67,7 @@ public final class WhenTranslator extends AbstractTranslator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsStatement translate() {
|
private JsNode translate() {
|
||||||
if (expressionToMatch != null && JsAstUtils.isEmptyExpression(expressionToMatch)) {
|
if (expressionToMatch != null && JsAstUtils.isEmptyExpression(expressionToMatch)) {
|
||||||
return JsEmpty.INSTANCE;
|
return JsEmpty.INSTANCE;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ public final class WhenTranslator extends AbstractTranslator {
|
|||||||
currentIf = nextIf;
|
currentIf = nextIf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultIf;
|
return resultIf != null ? resultIf : context().getEmptyExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
when {}
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user