JS backend: added @Nullable to JsNameRef#getName and added assertion to get more information for reproduce #EA-66032

This commit is contained in:
Zalim Bashorov
2015-03-13 18:57:43 +03:00
parent 7d3094a0f1
commit d6c70cc143
2 changed files with 6 additions and 3 deletions
@@ -7,6 +7,7 @@ package com.google.dart.compiler.backend.js.ast;
import com.google.dart.compiler.common.Symbol; import com.google.dart.compiler.common.Symbol;
import com.google.dart.compiler.util.AstUtil; import com.google.dart.compiler.util.AstUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* Represents a JavaScript expression that references a name. * Represents a JavaScript expression that references a name.
@@ -43,6 +44,7 @@ public final class JsNameRef extends JsExpressionImpl implements HasName {
return (name == null) ? ident : name.getIdent(); return (name == null) ? ident : name.getIdent();
} }
@Nullable
@Override @Override
public JsName getName() { public JsName getName() {
return name; return name;
@@ -248,9 +248,10 @@ public final class TranslationUtils {
JsExpression thenExpression = ensureNotNull.getThenExpression(); JsExpression thenExpression = ensureNotNull.getThenExpression();
if (thenExpression instanceof JsNameRef) { if (thenExpression instanceof JsNameRef) {
// associate (cache) ensureNotNull expression to new TemporaryConstVariable with same name. JsName name = ((JsNameRef) thenExpression).getName();
context.associateExpressionToLazyValue(ensureNotNull, assert name != null : "Unexpected state: getName() returned null for `" +thenExpression + "`, ensureNotNull: "+ ensureNotNull;
new TemporaryConstVariable(((JsNameRef) thenExpression).getName(), ensureNotNull)); // associate(cache) ensureNotNull expression to new TemporaryConstVariable with same name.
context.associateExpressionToLazyValue(ensureNotNull, new TemporaryConstVariable(name, ensureNotNull));
} }
return ensureNotNull; return ensureNotNull;