From 1d3d86023e9c7237103a4b3d9251c0c7748b8805 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 10 Dec 2018 16:21:44 +0300 Subject: [PATCH] Log NPE from getting operation reference in binary expression (EA-129499) --- .../org/jetbrains/kotlin/psi/KtBinaryExpression.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtBinaryExpression.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtBinaryExpression.java index 6e5571fb9dd..88c228ccea7 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtBinaryExpression.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtBinaryExpression.java @@ -23,6 +23,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.KtNodeTypes; +import java.util.Arrays; + public class KtBinaryExpression extends KtExpressionImpl implements KtOperationExpression { public KtBinaryExpression(@NotNull ASTNode node) { super(node); @@ -64,7 +66,12 @@ public class KtBinaryExpression extends KtExpressionImpl implements KtOperationE @Override @NotNull public KtOperationReferenceExpression getOperationReference() { - return (KtOperationReferenceExpression) findChildByType(KtNodeTypes.OPERATION_REFERENCE); + PsiElement operationReference = findChildByType(KtNodeTypes.OPERATION_REFERENCE); + if (operationReference == null) { + throw new NullPointerException("No operation reference for binary expression: " + Arrays.toString(getChildren())); + } + + return (KtOperationReferenceExpression) operationReference; } @NotNull @@ -72,3 +79,4 @@ public class KtBinaryExpression extends KtExpressionImpl implements KtOperationE return getOperationReference().getReferencedNameElementType(); } } +