From 61dee01b4e33970a5025ae556b90b0429d011fbc Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 17 Jun 2020 20:51:35 +0200 Subject: [PATCH] [java] diagnostics for EA-232194 GitOrigin-RevId: 28aea2c12dc0d21f747c247c1e59d250855db0aa --- .../com/intellij/psi/impl/compiled/ClsParsingUtil.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParsingUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParsingUtil.java index a1532fb5cf0a..91da385e8018 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParsingUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParsingUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl.compiled; import com.intellij.lang.java.lexer.JavaLexer; @@ -102,7 +102,9 @@ public class ClsParsingUtil { static PsiExpression psiToClsExpression(@NotNull PsiExpression expr, @NotNull ClsElementImpl parent) { if (expr instanceof PsiLiteralExpression) { - boolean forDecompiling = ((ClsFileImpl)parent.getContainingFile()).isForDecompiling(); + PsiFile file = parent.getContainingFile(); + if (!(file instanceof ClsFileImpl)) throw new ClassCastException("Unexpected: " + file); + boolean forDecompiling = ((ClsFileImpl)file).isForDecompiling(); PsiType type = forDecompiling ? PsiType.NULL : expr.getType(); Object value = forDecompiling ? null : ((PsiLiteralExpression)expr).getValue(); return new ClsLiteralExpressionImpl(parent, expr.getText(), type, value); @@ -141,7 +143,9 @@ public class ClsParsingUtil { return new ClsBinaryExpressionImpl(parent, sign, left, right); } - if (((ClsFileImpl)parent.getContainingFile()).isForDecompiling()) { + PsiFile file = parent.getContainingFile(); + if (!(file instanceof ClsFileImpl)) throw new ClassCastException("Unexpected: " + file); + if (((ClsFileImpl)file).isForDecompiling()) { return new ClsLiteralExpressionImpl(parent, expr.getText(), PsiType.NULL, null); }