From 843bc7956e7f09ad6354ec754dab30c8ddf86c12 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Thu, 19 Feb 2015 14:39:55 +0300 Subject: [PATCH] JS: made JsPropertyInitializer fields not nullable --- .../backend/js/ast/JsPropertyInitializer.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java index a33f1a035e2..b610b27f6ea 100644 --- a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java +++ b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java @@ -10,30 +10,26 @@ import org.jetbrains.annotations.NotNull; * Used in object literals to specify property values by name. */ public class JsPropertyInitializer extends SourceInfoAwareJsNode { + @NotNull private JsExpression labelExpr; + @NotNull private JsExpression valueExpr; - public JsPropertyInitializer(@NotNull JsExpression labelExpr) { - this.labelExpr = labelExpr; - } - public JsPropertyInitializer(@NotNull JsExpression labelExpr, @NotNull JsExpression valueExpr) { - this(labelExpr); + this.labelExpr = labelExpr; this.valueExpr = valueExpr; } + @NotNull public JsExpression getLabelExpr() { return labelExpr; } + @NotNull public JsExpression getValueExpr() { return valueExpr; } - public void setValueExpr(@NotNull JsExpression valueExpr) { - this.valueExpr = valueExpr; - } - @Override public void accept(JsVisitor v) { v.visitPropertyInitializer(this); @@ -48,8 +44,12 @@ public class JsPropertyInitializer extends SourceInfoAwareJsNode { @Override public void traverse(JsVisitorWithContext v, JsContext ctx) { if (v.visit(this, ctx)) { - labelExpr = v.accept(labelExpr); - valueExpr = v.accept(valueExpr); + JsExpression newLabel = v.accept(labelExpr); + JsExpression newValue = v.accept(valueExpr); + assert newLabel != null: "Label cannot be replaced with null"; + assert newValue != null: "Value cannot be replaced with null"; + labelExpr = newLabel; + valueExpr = newValue; } v.endVisit(this, ctx); }