mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix an issue with combinations of InstanceElement and Lambdas.
This commit is contained in:
@@ -176,8 +176,10 @@ class Evaluator(object):
|
||||
elif isinstance(element, pr.Keyword):
|
||||
# For False/True/None
|
||||
return [compiled.builtin.get_by_name(element.value)]
|
||||
elif isinstance(element, pr.Lambda):
|
||||
elif element.isinstance(pr.Lambda):
|
||||
return [er.LambdaWrapper(self, element)]
|
||||
elif element.isinstance(er.LambdaWrapper):
|
||||
return [element] # TODO this is no real evaluation.
|
||||
elif element.type == 'power':
|
||||
types = self._eval_atom(element.children[0])
|
||||
for trailer in element.children[1:]:
|
||||
|
||||
@@ -54,7 +54,10 @@ def wrap(evaluator, element):
|
||||
if isinstance(element, pr.Class):
|
||||
return Class(evaluator, element)
|
||||
elif isinstance(element, pr.Function):
|
||||
return Function(evaluator, element)
|
||||
if isinstance(element, pr.Lambda):
|
||||
return LambdaWrapper(evaluator, element)
|
||||
else:
|
||||
return Function(evaluator, element)
|
||||
elif isinstance(element, (pr.Module)) \
|
||||
and not isinstance(element, ModuleWrapper):
|
||||
return ModuleWrapper(evaluator, element)
|
||||
@@ -543,7 +546,8 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)):
|
||||
|
||||
|
||||
class LambdaWrapper(Function):
|
||||
pass
|
||||
def get_decorated_func(self):
|
||||
return self
|
||||
|
||||
|
||||
class LazyDict(object):
|
||||
@@ -583,6 +587,9 @@ class FunctionExecution(Executed):
|
||||
def get_return_types(self, check_yields=False):
|
||||
func = self.base
|
||||
|
||||
if func.isinstance(LambdaWrapper):
|
||||
return self._evaluator.eval_element(self.children[-1])
|
||||
|
||||
if func.listeners:
|
||||
# Feed the listeners, with the params.
|
||||
for listener in func.listeners:
|
||||
@@ -592,9 +599,6 @@ class FunctionExecution(Executed):
|
||||
# inserted params, not in the actual execution of the function.
|
||||
return []
|
||||
|
||||
if isinstance(func, LambdaWrapper):
|
||||
return self._evaluator.eval_element(self.children[-1])
|
||||
|
||||
if check_yields:
|
||||
types = []
|
||||
returns = self.yields
|
||||
|
||||
Reference in New Issue
Block a user