From 0d7fe0196fff47dea45bbd73832cb8bf70358557 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 5 Apr 2012 14:31:47 +0400 Subject: [PATCH] diagnostics for groovy type inference NPE --- .../plugins/groovy/lang/psi/impl/TypeInferenceHelper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java index 610ddc746113..d08878dc692b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java @@ -134,7 +134,7 @@ public class TypeInferenceHelper { } @Nullable - private static PsiType getInferredType(String varName, Instruction instruction, Instruction[] flow, GrControlFlowOwner scope) { + private static PsiType getInferredType(@NotNull String varName, @NotNull Instruction instruction, @NotNull Instruction[] flow, @NotNull GrControlFlowOwner scope) { final Pair>> pair = getDefUseMaps(scope); List> dfaResult = pair.second; @@ -216,7 +216,11 @@ public class TypeInferenceHelper { @Override @Nullable public PsiType compute() { - final PsiType original = getInferredType(instruction.getVariableName(), instruction.getInstructionToMixin(flow), flow, scope); + String varName = instruction.getVariableName(); + LOG.assertTrue(varName != null, scope.getText()); + ReadWriteVariableInstruction originalInstr = instruction.getInstructionToMixin(flow); + LOG.assertTrue(originalInstr != null, scope.getText()); + final PsiType original = getInferredType(varName, originalInstr, flow, scope); final PsiType mixin = instruction.inferMixinType(); if (mixin == null) return original; if (original == null) return mixin;