From d203d8f9371a5d284b1bab09e85b1777427c46fb Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 21 Jul 2014 21:51:56 +0200 Subject: [PATCH] bytecode-inferred annotations are only available for compiled elements (IDEA-127608) --- .../bytecodeAnalysis/ProjectBytecodeAnalysis.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java index 0b985b485c68..86b9dd101fd9 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java @@ -141,6 +141,9 @@ public class ProjectBytecodeAnalysis { @Nullable public PsiAnnotation findInferredAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN) { + if (!(listOwner instanceof PsiCompiledElement)) { + return null; + } if (annotationFQN.equals("org.jetbrains.annotations.NotNull")) { return findNotNullAnnotation(listOwner); } @@ -154,6 +157,9 @@ public class ProjectBytecodeAnalysis { @NotNull public PsiAnnotation[] findInferredAnnotations(@NotNull PsiModifierListOwner listOwner) { + if (!(listOwner instanceof PsiCompiledElement)) { + return PsiAnnotation.EMPTY_ARRAY; + } return collectInferredAnnotations(listOwner); } @@ -249,6 +255,8 @@ public class ProjectBytecodeAnalysis { } public static int getKey(@NotNull PsiModifierListOwner owner) throws IOException { + LOG.assertTrue(owner instanceof PsiCompiledElement, owner); + if (owner instanceof PsiMethod) { return BytecodeAnalysisConverter.getInstance().mkPsiKey((PsiMethod)owner, new Out()); }