From: Ilya.Kazakevich Date: Thu, 24 Sep 2015 21:51:51 +0000 (+0300) Subject: PY-16920 delegated methods in custom type were not filtered X-Git-Tag: dbe/142.5132~1 X-Git-Url: https://git.jetbrains.org/?p=idea%2Fcommunity.git;a=commitdiff_plain;h=fb232a848f54d90af64237f0247d50899b192037 PY-16920 delegated methods in custom type were not filtered 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 --- diff --git a/python/src/com/jetbrains/python/PyCustomType.java b/python/src/com/jetbrains/python/PyCustomType.java index 0567d467e81d..bb1190539251 100644 --- a/python/src/com/jetbrains/python/PyCustomType.java +++ b/python/src/com/jetbrains/python/PyCustomType.java @@ -253,9 +253,21 @@ public class PyCustomType implements PyClassLikeType { } @Override - public void visitMembers(@NotNull final Processor processor, final boolean inherited, @NotNull TypeEvalContext context) { + public final void visitMembers(@NotNull final Processor 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() { + @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); } }