added more descriptive assertions if we get nulls when compiling
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.translate.reference;
|
package org.jetbrains.k2js.translate.reference;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.dart.compiler.backend.js.ast.JsExpression;
|
import com.google.dart.compiler.backend.js.ast.JsExpression;
|
||||||
import com.google.dart.compiler.backend.js.ast.JsName;
|
import com.google.dart.compiler.backend.js.ast.JsName;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -57,6 +58,7 @@ public final class ReferenceTranslator {
|
|||||||
public static JsExpression translateAsLocalNameReference(@NotNull DeclarationDescriptor referencedDescriptor,
|
public static JsExpression translateAsLocalNameReference(@NotNull DeclarationDescriptor referencedDescriptor,
|
||||||
@NotNull TranslationContext context) {
|
@NotNull TranslationContext context) {
|
||||||
DeclarationDescriptor effectiveDescriptor = getReferencedDescriptor(referencedDescriptor, context);
|
DeclarationDescriptor effectiveDescriptor = getReferencedDescriptor(referencedDescriptor, context);
|
||||||
|
Preconditions.checkNotNull(effectiveDescriptor, "Could not find DeclarationDescriptor for %s", referencedDescriptor);
|
||||||
return context.getNameForDescriptor(effectiveDescriptor).makeRef();
|
return context.getNameForDescriptor(effectiveDescriptor).makeRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,9 +70,11 @@ public final class ReferenceTranslator {
|
|||||||
DeclarationDescriptor effectiveDescriptor;
|
DeclarationDescriptor effectiveDescriptor;
|
||||||
if (context.isEcma5() && referencedDescriptor instanceof PropertyAccessorDescriptor) {
|
if (context.isEcma5() && referencedDescriptor instanceof PropertyAccessorDescriptor) {
|
||||||
effectiveDescriptor = ((PropertyAccessorDescriptor) referencedDescriptor).getCorrespondingProperty();
|
effectiveDescriptor = ((PropertyAccessorDescriptor) referencedDescriptor).getCorrespondingProperty();
|
||||||
|
Preconditions.checkNotNull(effectiveDescriptor, "No correspondingProperty available for descriptor %s", referencedDescriptor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
effectiveDescriptor = referencedDescriptor;
|
effectiveDescriptor = referencedDescriptor;
|
||||||
|
Preconditions.checkNotNull(effectiveDescriptor, "No referencedDescriptor available");
|
||||||
}
|
}
|
||||||
return effectiveDescriptor;
|
return effectiveDescriptor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,13 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.translate.utils;
|
package org.jetbrains.k2js.translate.utils;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||||
@@ -188,6 +190,8 @@ public final class BindingUtils {
|
|||||||
@NotNull JetReferenceExpression reference) {
|
@NotNull JetReferenceExpression reference) {
|
||||||
DeclarationDescriptor referencedDescriptor = getNullableDescriptorForReferenceExpression(context, reference);
|
DeclarationDescriptor referencedDescriptor = getNullableDescriptorForReferenceExpression(context, reference);
|
||||||
assert referencedDescriptor != null : "Reference expression must reference a descriptor.";
|
assert referencedDescriptor != null : "Reference expression must reference a descriptor.";
|
||||||
|
Preconditions.checkNotNull(referencedDescriptor, "Reference expression must reference a descriptor for reference %s at %s", reference.getText(),
|
||||||
|
DiagnosticUtils.atLocation(reference));
|
||||||
return referencedDescriptor;
|
return referencedDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user