JS backend: fix compiler crash on empty then if block
#EA-68941 fixed
This commit is contained in:
@@ -41,4 +41,8 @@ public class IfExpressionTest extends AbstractExpressionTest {
|
||||
public void testNestedIf() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testWithEmptyBlocks() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -215,12 +215,12 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
boolean isKotlinExpression = BindingContextUtilPackage.isUsedAsExpression(expression, context.bindingContext());
|
||||
|
||||
JetExpression thenExpression = expression.getThen();
|
||||
assert thenExpression != null : "then expression should not be null: " + expression.getText();
|
||||
JetExpression elseExpression = expression.getElse();
|
||||
|
||||
JsStatement thenStatement = Translation.translateAsStatementAndMergeInBlockIfNeeded(thenExpression, context);
|
||||
JsStatement elseStatement = (elseExpression != null) ? Translation.translateAsStatementAndMergeInBlockIfNeeded(elseExpression,
|
||||
context) : null;
|
||||
JsStatement thenStatement =
|
||||
thenExpression != null ? Translation.translateAsStatementAndMergeInBlockIfNeeded(thenExpression, context) : null;
|
||||
JsStatement elseStatement =
|
||||
elseExpression != null ? Translation.translateAsStatementAndMergeInBlockIfNeeded(elseExpression, context) : null;
|
||||
|
||||
if (isKotlinExpression) {
|
||||
JsExpression jsThenExpression = JsAstUtils.extractExpressionFromStatement(thenStatement);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
var r = ""
|
||||
if (r != "") else r += "O"
|
||||
if (r == "O") r += "K" else;
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user