Commit f1930c2d authored by da_woods's avatar da_woods

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)
parent 7f5608b9
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment