PY-16920 delegated methods in custom type were not filtered
authorIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Thu, 24 Sep 2015 21:51:51 +0000 (00:51 +0300)
committerIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Thu, 24 Sep 2015 21:51:51 +0000 (00:51 +0300)
Manager is intersection of BaseManager and QuerySet. Not all methods should be inherited from QuerySet, but only those with out of "queryset_only" mark. It has been done for resolving , but not for method visiting

python/src/com/jetbrains/python/PyCustomType.java

index 0567d467e81d91d4151096f7b8bb882c6e5756ca..bb11905392517089566007d8ddd1058c8900f749 100644 (file)
@@ -253,9 +253,21 @@ public class PyCustomType implements PyClassLikeType {
   }
 
   @Override
-  public void visitMembers(@NotNull final Processor<PsiElement> processor, final boolean inherited, @NotNull TypeEvalContext context) {
+  public final void visitMembers(@NotNull final Processor<PsiElement> processor, final boolean inherited, @NotNull final TypeEvalContext context) {
     for (final PyClassLikeType type : myTypesToMimic) {
-      type.visitMembers(processor, inherited, context);
+      // Only visit methods that are allowed by filter (if any)
+      type.visitMembers(new Processor<PsiElement>() {
+        @Override
+        public boolean process(final PsiElement t) {
+          if (!(t instanceof PyElement)) {
+            return true;
+          }
+          if (myFilter == null || myFilter.process((PyElement)t)) {
+            return processor.process(t);
+          }
+          return true;
+        }
+      }, inherited, context);
     }
   }