Make the order of overloaded functions correct

This commit is contained in:
Dave Halter
2019-08-30 01:11:11 +02:00
parent 04bc9eb62c
commit 286d2c9b1a
5 changed files with 17 additions and 6 deletions

View File

@@ -42,7 +42,7 @@ class ExecutedParamName(ParamName):
matches = any(c1.is_sub_class_of(c2) matches = any(c1.is_sub_class_of(c2)
for c1 in argument_values for c1 in argument_values
for c2 in annotations.gather_annotation_classes()) for c2 in annotations.gather_annotation_classes())
debug.dbg("signature compare %s: %s <=> %s", debug.dbg("param compare %s: %s <=> %s",
matches, argument_values, annotations, color='BLUE') matches, argument_values, annotations, color='BLUE')
return matches return matches

View File

@@ -55,6 +55,8 @@ class AbstractSignature(_SignatureMixin):
raise NotImplementedError raise NotImplementedError
def __repr__(self): def __repr__(self):
if self.value is self._function_value:
return '<%s: %s>' % (self.__class__.__name__, self.value)
return '<%s: %s, %s>' % (self.__class__.__name__, self.value, self._function_value) return '<%s: %s, %s>' % (self.__class__.__name__, self.value, self._function_value)

View File

@@ -127,7 +127,8 @@ class FunctionValue(use_metaclass(CachedMetaClass, FunctionMixin, FunctionAndCla
if overloaded_funcs: if overloaded_funcs:
return OverloadedFunctionValue( return OverloadedFunctionValue(
function, function,
[create(f) for f in overloaded_funcs] # Get them into the correct order: lower line first.
list(reversed([create(f) for f in overloaded_funcs]))
) )
return function return function

View File

@@ -281,11 +281,19 @@ d = dict(a=3, b='')
x, = d.values() x, = d.values()
#? int() str() #? int() str()
x x
#? int() str() #? int()
d['a'] d['a']
#? int() str() None #? int() str() None
d.get('a') d.get('a')
some_dct = dict({'a': 1, 'b': ''}, a=1.0)
#? float()
some_dct['a']
#? str()
some_dct['b']
#? int() float() str()
some_dct['c']
# ----------------- # -----------------
# with variable as index # with variable as index
# ----------------- # -----------------

View File

@@ -266,11 +266,11 @@ def _params(Script, source, line=None, column=None):
def test_int_params(Script): def test_int_params(Script):
sig1, sig2 = Script('int(').call_signatures() sig1, sig2 = Script('int(').call_signatures()
# int is defined as: `int(x[, base])` # int is defined as: `int(x[, base])`
assert len(sig1.params) == 2 assert len(sig1.params) == 1
assert sig1.params[0].name == 'x' assert sig1.params[0].name == 'x'
assert sig1.params[1].name == 'base' assert len(sig2.params) == 2
assert len(sig2.params) == 1
assert sig2.params[0].name == 'x' assert sig2.params[0].name == 'x'
assert sig2.params[1].name == 'base'
def test_pow_params(Script): def test_pow_params(Script):