diff --git a/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java b/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java index f5e3f95363c6..73c0a31e9b45 100644 --- a/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java +++ b/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java @@ -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 resolveLocally(@NotNull PyReferenceExpression referenceExpression) { final String referenceName = referenceExpression.getName(); - if (referenceName == null) { + if (referenceName == null || referenceExpression.isQualified()) { return Collections.emptyList(); } diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 82fa720aaf9c..4eb2a26cce7f 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -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 getTypeEvalContexts(@NotNull PyExpression element) { return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(), TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());