From: daniloaf@daniloaf-PC Date: Fri, 18 Dec 2009 07:26:19 +0000 (-0300) Subject: Fixing best match removing ambiguity with pointer and reference X-Git-Tag: 0.13.beta0~353^2~28 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0888723ecdc97f8213b57c324ecfdaa03b9196cf;p=cython.git Fixing best match removing ambiguity with pointer and reference --- diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index c23c6aee..8fa3836b 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1,3 +1,4 @@ + # # Pyrex - Types # @@ -1383,10 +1384,12 @@ class CReferenceType(CType): if other_type is error_type: return 1 if other_type.is_ptr: - if other_type.base_type == self.base_type: - return 1 - else: - pass + return 0 + #print self, other_type + #if other_type.base_type == self.base_type: + # return 1 + #else: + # pass #TODO: should send a warning message: initialization from incompatible pointer type (in C/C++) if other_type == self.base_type: return 1 @@ -2240,8 +2243,9 @@ def best_match(args, functions, pos): src_type = args[i].type dst_type = func_type.args[i].type if dst_type.assignable_from(src_type): - #print src_type, src_type.is_pyobject, dst_type, dst_type.is_pyobject - if src_type == dst_type or (dst_type.is_reference and src_type == dst_type.base_type): + if src_type == dst_type or (dst_type.is_reference and \ + src_type == dst_type.base_type) or \ + dst_type.same_as(src_type): pass # score 0 elif is_promotion(src_type, dst_type): score[2] += 1 diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 6596c714..8d64aa59 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -311,11 +311,11 @@ class Scope(object): entry.in_cinclude = self.in_cinclude if name: entry.qualified_name = self.qualify_name(name) -# if name in entries and self.is_cpp(): -# entries[name].overloaded_alternatives.append(entry) -# else: -# entries[name] = entry - entries[name] = entry + if name in entries and self.is_cpp(): + entries[name].overloaded_alternatives.append(entry) + else: + entries[name] = entry +# entries[name] = entry entry.scope = self entry.visibility = visibility return entry