From 229c254abc613d7183f16a75b94fe4663209abcc Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Fri, 12 Dec 2014 15:58:23 +0300 Subject: [PATCH] Fixed collecting wrong '__contains__' attribute for structural types The 'x in y' expression implies that 'y' has the '__contains__' attribute, while our references in qualified expressions tell that the 'x' references the name '__contains__'. In order to fix this we have to treat the operators with a receiver on the right side of the expression differently. --- .../psi-api/src/com/jetbrains/python/PyNames.java | 2 +- .../python/psi/impl/PyNamedParameterImpl.java | 14 +++++++++----- .../jetbrains/python/psi/types/PyTypeChecker.java | 2 +- .../testSrc/com/jetbrains/python/PyTypeTest.java | 9 +++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/python/psi-api/src/com/jetbrains/python/PyNames.java b/python/psi-api/src/com/jetbrains/python/PyNames.java index b82576428c3c..21e5be632d59 100644 --- a/python/psi-api/src/com/jetbrains/python/PyNames.java +++ b/python/psi-api/src/com/jetbrains/python/PyNames.java @@ -472,7 +472,7 @@ public class PyNames { } public static boolean isRightOperatorName(@Nullable String name) { - return name != null && name.matches("__r[a-z]+__"); + return name != null && (name.matches("__r[a-z]+__") || CONTAINS.equals(name)); } /** diff --git a/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java b/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java index 32443e54a6c9..222a98df8a5f 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java @@ -306,11 +306,15 @@ public class PyNamedParameterImpl extends PyBaseElementImpl