diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index c16a56cb..cc93f163 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -428,26 +428,24 @@ class Evaluator(object): context = iterable.SequenceLiteralContext(self, context, atom) return ContextSet(context) - def eval_trailer(self, context, types, trailer): + def eval_trailer(self, context, base_contexts, trailer): trailer_op, node = trailer.children[:2] if node == ')': # `arglist` is optional. node = () if trailer_op == '[': - return iterable.py__getitem__(self, context, types, trailer) + return iterable.py__getitem__(self, context, base_contexts, trailer) else: - context_set = ContextSet() - for typ in types: - debug.dbg('eval_trailer: %s in scope %s', trailer, typ) - if trailer_op == '.': - context_set |= typ.py__getattribute__( - name_context=context, - name_or_str=node - ) - elif trailer_op == '(': - arguments = param.TreeArguments(self, context, node, trailer) - context_set |= self.execute(typ, arguments) - return context_set + debug.dbg('eval_trailer: %s in %s', trailer, base_contexts) + if trailer_op == '.': + return base_contexts.py__getattribute__( + name_context=context, + name_or_str=node + ) + else: + assert trailer_op == '(' + arguments = param.TreeArguments(self, context, node, trailer) + return base_contexts.execute(arguments) @debug.increase_indent def execute(self, obj, arguments): diff --git a/jedi/evaluate/iterable.py b/jedi/evaluate/iterable.py index be62ecb0..524d843f 100644 --- a/jedi/evaluate/iterable.py +++ b/jedi/evaluate/iterable.py @@ -61,9 +61,16 @@ class BuiltinMethod(object): self._method = method self._builtin_func = builtin_func + # TODO it seems kind of stupid that we have to overwrite 3 methods here. def py__call__(self, params): return self._method(self._builtin_context) + def execute(self, *args, **kwargs): + return self._builtin_context.evaluator.execute(self, *args, **kwargs) + + def execute_evaluated(self, *args, **kwargs): + return self._builtin_context.evaluator.execute_evaluated(self, *args, **kwargs) + def __getattr__(self, name): return getattr(self._builtin_func, name)