From b9f205b61f99228cd7da282ef41fd7f1ca62c4e0 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Mon, 16 Nov 2015 19:25:58 +0300 Subject: [PATCH] Use TypeEvalContext.userInitiated() for replace tuple with list quickfix (PY-15558) The default type evaluation context doesn't allow to perform proper follow assignments chain even for AST-based trees now (which is consistent with stub-based trees). We have to specify the appropriate context manually. --- .../inspections/quickfix/PyReplaceTupleWithListQuickFix.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/inspections/quickfix/PyReplaceTupleWithListQuickFix.java b/python/src/com/jetbrains/python/inspections/quickfix/PyReplaceTupleWithListQuickFix.java index d480d339bb36..53254e72e2e7 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/PyReplaceTupleWithListQuickFix.java +++ b/python/src/com/jetbrains/python/inspections/quickfix/PyReplaceTupleWithListQuickFix.java @@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement; import com.jetbrains.python.PyBundle; import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.resolve.PyResolveContext; +import com.jetbrains.python.psi.types.TypeEvalContext; import org.jetbrains.annotations.NotNull; public class PyReplaceTupleWithListQuickFix implements LocalQuickFix { @@ -46,7 +47,9 @@ public class PyReplaceTupleWithListQuickFix implements LocalQuickFix { PySubscriptionExpression subscriptionExpression = (PySubscriptionExpression)targets[0]; if (subscriptionExpression.getOperand() instanceof PyReferenceExpression) { PyReferenceExpression referenceExpression = (PyReferenceExpression)subscriptionExpression.getOperand(); - element = referenceExpression.followAssignmentsChain(PyResolveContext.defaultContext()).getElement(); + final TypeEvalContext context = TypeEvalContext.userInitiated(project, element.getContainingFile()); + final PyResolveContext resolveContext = PyResolveContext.noImplicits().withTypeEvalContext(context); + element = referenceExpression.followAssignmentsChain(resolveContext).getElement(); if (element instanceof PyParenthesizedExpression) { final PyExpression expression = ((PyParenthesizedExpression)element).getContainedExpression(); replaceWithListLiteral(element, (PyTupleExpression)expression);