PY-21906 Fixed: Code inspection stops working with StackOverflowError in PassExecutorService

Don't resolve qualified references in PyResolveUtil.resolveLocally.
This commit is contained in:
Semyon Proshev
2017-05-10 15:55:12 +03:00
parent 2b763f64f6
commit 3b69b062b1
2 changed files with 13 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -108,7 +108,7 @@ public class PyResolveUtil {
public static Collection<PsiElement> resolveLocally(@NotNull PyReferenceExpression referenceExpression) {
final String referenceName = referenceExpression.getName();
if (referenceName == null) {
if (referenceName == null || referenceExpression.isQualified()) {
return Collections.emptyList();
}
@@ -1703,6 +1703,17 @@ public class PyTypeTest extends PyTestCase {
"expr = min(l)");
}
// PY-21906
public void testSOFOnTransitiveNamedTupleFields() {
final PyExpression expression = parseExpr("from collections import namedtuple\n" +
"class C:\n" +
" FIELDS = ('a', 'b')\n" +
"FIELDS = C.FIELDS\n" +
"expr = namedtuple('Tup', FIELDS)");
getTypeEvalContexts(expression).forEach(context -> context.getType(expression));
}
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());