cython
cython copied to clipboard
Improve C++ non-member operator lookup
Supersedes https://github.com/cython/cython/pull/4542 hopefully and fixes https://github.com/cython/cython/issues/4539
This PR is a little less drastic in the changes it makes - it doesn't try to move complete validation into PyrexTypes.best_match (given that for most functions the validation happens in analyse_types).
It modifies best_match
slightly so it can take an optional arg0 argument (that only applies to non-member functions). This allows member functions to be compared directly with nonmember functions so that all the alternatives for operators (member functions, non-member functions declared in a global scope, non-member functions declared in a class scope) can be evaluated in one go.
In the case where a single argument exists it evaluates the suitability in the UnopNode.analyse_types
by attempting coercion. This basically matches what BinopNode
currently does so seems a sensible approach.
Mentioning the related issue here, so github links them: #4539