From 184ff414056f23bacdbb2946ff58d36fafd77617 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 8 Nov 2012 13:25:18 +0400 Subject: [PATCH] fixed PY-7974 NPE at com.jetbrains.python.codeInsight.intentions.SpecifyTypeInPy3AnnotationsIntention.isAvailable --- .../SpecifyTypeInPy3AnnotationsIntention.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java index 82378cbd170f..f9cb3ae96c40 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java @@ -57,10 +57,13 @@ public class SpecifyTypeInPy3AnnotationsIntention implements IntentionAction { if (callExpression != null && callExpression.resolveCalleeFunction(PyResolveContext.defaultContext()) != null) { PyAssignmentStatement assignmentStatement = PsiTreeUtil.getParentOfType(elementAt, PyAssignmentStatement.class); if (assignmentStatement != null) { - PyType type = assignmentStatement.getAssignedValue().getType(TypeEvalContext.slow()); - if (type == null || type instanceof PyReturnTypeReference) { - myText = PyBundle.message("INTN.specify.returt.type.in.annotation"); - return true; + final PyExpression assignedValue = assignmentStatement.getAssignedValue(); + if (assignedValue != null) { + PyType type = assignedValue.getType(TypeEvalContext.slow()); + if (type == null || type instanceof PyReturnTypeReference) { + myText = PyBundle.message("INTN.specify.returt.type.in.annotation"); + return true; + } } } }