From d6c70cc1434f87a3f8dee678589ca1082b0d94d8 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Fri, 13 Mar 2015 18:57:43 +0300 Subject: [PATCH] JS backend: added @Nullable to JsNameRef#getName and added assertion to get more information for reproduce #EA-66032 --- .../com/google/dart/compiler/backend/js/ast/JsNameRef.java | 2 ++ .../kotlin/js/translate/utils/TranslationUtils.java | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java index 6f979d7d839..5ff31b2eef5 100644 --- a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java +++ b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java @@ -7,6 +7,7 @@ package com.google.dart.compiler.backend.js.ast; import com.google.dart.compiler.common.Symbol; import com.google.dart.compiler.util.AstUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * 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(); } + @Nullable @Override public JsName getName() { return name; diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java index e6ae6c8ef38..5dd7384b6b6 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java @@ -248,9 +248,10 @@ public final class TranslationUtils { JsExpression thenExpression = ensureNotNull.getThenExpression(); if (thenExpression instanceof JsNameRef) { - // associate (cache) ensureNotNull expression to new TemporaryConstVariable with same name. - context.associateExpressionToLazyValue(ensureNotNull, - new TemporaryConstVariable(((JsNameRef) thenExpression).getName(), ensureNotNull)); + JsName name = ((JsNameRef) thenExpression).getName(); + assert name != null : "Unexpected state: getName() returned null for `" +thenExpression + "`, ensureNotNull: "+ ensureNotNull; + // associate(cache) ensureNotNull expression to new TemporaryConstVariable with same name. + context.associateExpressionToLazyValue(ensureNotNull, new TemporaryConstVariable(name, ensureNotNull)); } return ensureNotNull;