mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Overloaded functions now return values even if nothing matches
This commit is contained in:
@@ -72,10 +72,8 @@ class FunctionMixin(object):
|
|||||||
return LambdaName(self)
|
return LambdaName(self)
|
||||||
return ContextName(self, self.tree_node.name)
|
return ContextName(self, self.tree_node.name)
|
||||||
|
|
||||||
def py__call__(self, arguments, need_param_match=False):
|
def py__call__(self, arguments):
|
||||||
function_execution = self.get_function_execution(arguments)
|
function_execution = self.get_function_execution(arguments)
|
||||||
if need_param_match and not function_execution.matches_signature():
|
|
||||||
return NO_CONTEXTS
|
|
||||||
return function_execution.infer()
|
return function_execution.infer()
|
||||||
|
|
||||||
def get_function_execution(self, arguments=None):
|
def get_function_execution(self, arguments=None):
|
||||||
@@ -354,10 +352,23 @@ class OverloadedFunctionContext(FunctionMixin, ContextWrapper):
|
|||||||
|
|
||||||
def py__call__(self, arguments):
|
def py__call__(self, arguments):
|
||||||
debug.dbg("Execute overloaded function %s", self._wrapped_context, color='BLUE')
|
debug.dbg("Execute overloaded function %s", self._wrapped_context, color='BLUE')
|
||||||
return ContextSet.from_sets(
|
function_executions = []
|
||||||
f.py__call__(arguments=arguments, need_param_match=True)
|
context_set = NO_CONTEXTS
|
||||||
for f in self.overloaded_functions
|
matched = False
|
||||||
)
|
for f in self.overloaded_functions:
|
||||||
|
function_execution = f.get_function_execution(arguments)
|
||||||
|
function_executions.append(function_execution)
|
||||||
|
if function_execution.matches_signature():
|
||||||
|
matched = True
|
||||||
|
return function_execution.infer()
|
||||||
|
|
||||||
|
if matched:
|
||||||
|
return context_set
|
||||||
|
|
||||||
|
if self.evaluator.is_analysis:
|
||||||
|
# In this case we want precision.
|
||||||
|
return NO_CONTEXTS
|
||||||
|
return ContextSet.from_sets(fe.infer() for fe in function_executions)
|
||||||
|
|
||||||
def get_matching_functions(self, arguments):
|
def get_matching_functions(self, arguments):
|
||||||
for f in self.overloaded_functions:
|
for f in self.overloaded_functions:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ def we_can_has_sequence(p, q, r, s, t, u):
|
|||||||
t[1]
|
t[1]
|
||||||
#? ["append"]
|
#? ["append"]
|
||||||
u.a
|
u.a
|
||||||
#?
|
#? float() list()
|
||||||
u[1.0]
|
u[1.0]
|
||||||
#? float()
|
#? float()
|
||||||
u[1]
|
u[1]
|
||||||
|
|||||||
Reference in New Issue
Block a user