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