[Chapel Merge] Resolve some issues with finding primary and secon

Branch: refs/heads/master
Revision: c104a39
Author: lydia-duncan
Log Message:

Merge pull request #17684 from lydia-duncan/otherModOp

Resolve some issues with finding primary and secondary operator methods
[reviewed by @mppf]

This change handles a few things, but was originally motivated by not being
able to find primary and secondary operator methods on classes when in a
scope that did not have their definition point already visible (remember: primary
and secondary methods are always visible, regardless of if the scope where they
are defined has been imported or used in the current scope).

Other issues addressed:

  • not all operator calls were following the method visibility path during function
    resolution.
  • Operator standalone functions were not having their privacy modifiers respected
    during function resolution.
  • Operator calls were only checking the definition point of one of the arguments,
    meaning that we wouldn't necessarily find operator methods on the other.
  • The filter applied when a use has a limitation clause or for imports of symbols
    was always assuming the call was a method call, so in the case of operators we
    were only filtering the second argument (if there was one). This meant that if an
    operator call involved two different types, we wouldn't notice if the first type was
    explicitly included or excluded by a use or import statement and so wouldn't behave
    appropriately when visiting that scope.

Resolves Cray/chapel-private#1975
Resolves Cray/chapel-private#1731
Resolves Cray/chapel-private#1719

Adds five new tests that cover:

  • Calling an operator on a type when the type is returned (and so the use that
    would find its definition point is not visible)
  • Calling an operator on a type that has been passed as an argument when the
    operator method is defined on both types
  • Calling an operator on a type that has been passed as an argument when the
    operator method is defined on the first argument type
  • Calling an operator on a type that has been passed as an argument when the
    operator method is defined on the second argument type
  • Calling an operator on a type that has been passed as an argument when an
    operator method is defined on neither argument type

Passed a full paratest with futures

Modified Files:
A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod-twoTypes.chpl

A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod-twoTypes.good
A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod-twoTypes2.chpl
A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod-twoTypes2.good
A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod-unrelatedType.chpl
A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod-unrelatedType.good
A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod.chpl
A test/functions/operatorOverloads/operatorMethods/secondaryInNonVisibleMod.good
A test/functions/operatorOverloads/operatorMethods/typeReturned.chpl
A test/functions/operatorOverloads/operatorMethods/typeReturned.good
M compiler/include/ImportStmt.h
M compiler/include/UseStmt.h
M compiler/resolution/visibleFunctions.cpp

Compare: https://github.com/chapel-lang/chapel/compare/116edf56fe07...c104a39288f2