summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorda_woods <n/a>2015-05-16 17:15:06 +0100
committerda_woods <n/a>2015-09-19 21:10:00 +0100
commitf1930c2d670b4ad71a0c8c8075fb659d966afc27 (patch)
treedefc8e0d9ed0e3798cb4df1d7ce1b427ceb1f4c8
parent7f5608b96be4c9af9b2d375ca52782bc27db6484 (diff)
downloadcython-f1930c2d670b4ad71a0c8c8075fb659d966afc27.tar.gz
Further operator finding fixes
It wasn't finding nonmember operators with a class of the form: cdef cppclass C: C operator+(const C&, int) (i.e. with the class specified first)
-rw-r--r--Cython/Compiler/Symtab.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py
index e311e76f9..053de026e 100644
--- a/Cython/Compiler/Symtab.py
+++ b/Cython/Compiler/Symtab.py
@@ -838,19 +838,23 @@ class Scope(object):
# look-up nonmember methods listed within a class
method_alternatives = []
- if (len(operands)==2 # binary operators only
- and operands[1].type.is_cpp_class):
- obj_type = operands[1].type
- method = obj_type.scope.lookup("operator%s" % operator)
- if method is not None:
- # also allow lookup with things defined in the global scope
- method_alternatives = method.all_alternatives()
+ if len(operands)==2: # binary operators only
+ for n in range(2):
+ if operands[n].type.is_cpp_class:
+ obj_type = operands[n].type
+ method = obj_type.scope.lookup("operator%s" % operator)
+ if method is not None:
+ method_alternatives += method.all_alternatives()
if (not method_alternatives) and (not function_alternatives):
return None
+
+ # select the unique alternatives
+ all_alternatives = list(set(method_alternatives+function_alternatives))
+
return PyrexTypes.best_match(operands,
- method_alternatives+function_alternatives)
+ all_alternatives)
def lookup_operator_for_types(self, pos, operator, types):
from .Nodes import Node