[Chapel Merge] Initial operator changes implementation

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

Merge pull request #17103 from lydia-duncan/operatorMethods

Initial operator changes implementation
[reviewed by @mppf]

Adds support for operator methods, as well as declaring operator functions
and methods with the new “operator” keyword.

Resolves #16730
Resolves #16929

Adds `operator` as a keyword to the parser, usable when declaring a function in place of `proc` or `iter`.

Adds a new flag, FLAG_OPERATOR, which is explicitly applied to functions and
methods declared with the operator keyword and implicitly applied to functions
with recognized names for now. The place where the flag is attached to functions
with particular names is a good place to add a deprecation warning (but that will
be handled in a later PR).

When an operator is declared, we also will set its this intent tag to INTENT_TYPE,
so that if it does end up being a method, it will be recognized as a type method
and handled appropriately (by removing the “this” arg and its corresponding
actual for all calls after resolution).

Removes a check in normalize that prevents operators from being methods.

Adjusts several stages of function resolution to handle operator methods. Allows
calls to operators to either contain or not contain the method token and “this”
actual, and allows operator functions to either contain or not contain the
corresponding formals. This involves skipping those actuals or formals when
checking if a function is a match and when determining which of two
functions is a more specific match. It also involves adjusting the call appropriately
when a match is found if extra actuals are present or if certain actuals are missing.

During disambiguation, pulled common code out of testArgMapping and into a
helper function - this had the happy effect of also fixing an error where we were
passing the wrong formal and function to canDispatch (though it seems as though
there was not a major impact from doing so)

Adds a number of tests to lock in the expected behavior, including:

  • primary, secondary and tertiary operator methods
  • methods on classes and methods on records
  • operators where the arguments are the generic version of the type
  • operators where the arguments are a particular instantiation of the generic type
  • operators when inheritance is involved (currently a future, will be handled later)
  • case where two types define an identical operator as a method (and so are in conflict)
  • case where the operator is defined a type that matches the second argument but not
    the first
  • case where an operator has been defined as a method that conflicts with a operator
    defined as a standalone function
  • case where an operator has been defined with the same name as a standalone operator
    but the two are not in conflict
  • case where a type has an operator defined as a method and another operator defined as
    a standalone function
  • operator keyword applied to a standalone operator function

Removes two tests that were locking in that operators could not be methods. Also updates
a future requesting operator methods for the current vision for the feature and resolves that

Passed a full paratest with futures

Modified Files:
A test/functions/operatorOverloads/operatorMethods/definedOnClass.chpl
A test/functions/operatorOverloads/operatorMethods/definedOnClass.good
A test/functions/operatorOverloads/operatorMethods/generics.chpl
A test/functions/operatorOverloads/operatorMethods/generics.good
A test/functions/operatorOverloads/operatorMethods/genericsInstantiationBad.chpl
A test/functions/operatorOverloads/operatorMethods/genericsInstantiationBad.good
A test/functions/operatorOverloads/operatorMethods/genericsInstantiationGood.chpl
A test/functions/operatorOverloads/operatorMethods/genericsInstantiationGood.good
A test/functions/operatorOverloads/operatorMethods/inheritance.bad
A test/functions/operatorOverloads/operatorMethods/inheritance.chpl
A test/functions/operatorOverloads/operatorMethods/inheritance.future
A test/functions/operatorOverloads/operatorMethods/inheritance.good
A test/functions/operatorOverloads/operatorMethods/methodConflict.chpl
A test/functions/operatorOverloads/operatorMethods/methodConflict.good
A test/functions/operatorOverloads/operatorMethods/methodOnSecondArgType.chpl
A test/functions/operatorOverloads/operatorMethods/methodOnSecondArgType.good
A test/functions/operatorOverloads/operatorMethods/primaryMethod.chpl
A test/functions/operatorOverloads/operatorMethods/primaryMethod.good
A test/functions/operatorOverloads/operatorMethods/secondaryMethod.chpl
A test/functions/operatorOverloads/operatorMethods/secondaryMethod.good
A test/functions/operatorOverloads/operatorMethods/standaloneConflict.chpl
A test/functions/operatorOverloads/operatorMethods/standaloneConflict.good
A test/functions/operatorOverloads/operatorMethods/standaloneDiffArgs.chpl
A test/functions/operatorOverloads/operatorMethods/standaloneDiffArgs.good
A test/functions/operatorOverloads/operatorMethods/standaloneDiffOp.chpl
A test/functions/operatorOverloads/operatorMethods/standaloneDiffOp.good
A test/functions/operatorOverloads/operatorMethods/tertiaryMethod.chpl
A test/functions/operatorOverloads/operatorMethods/tertiaryMethod.good
A test/functions/operatorOverloads/withKeyword.chpl
A test/functions/operatorOverloads/withKeyword.good
R test/classes/figueroa/ErroneousOpOverloading1.chpl
R test/classes/figueroa/ErroneousOpOverloading1.good
R test/classes/figueroa/ErroneousOpOverloading2.chpl
R test/classes/figueroa/ErroneousOpOverloading2.good
R test/classes/hilde/methodAssignment.bad
R test/classes/hilde/methodAssignment.future
M compiler/AST/AggregateType.cpp
M compiler/AST/build.cpp
M compiler/include/bison-chapel.h
M compiler/include/build.h
M compiler/include/flags_list.h
M compiler/include/flex-chapel.h
M compiler/parser/bison-chapel.cpp
M compiler/parser/chapel.lex
M compiler/parser/chapel.ypp
M compiler/parser/flex-chapel.cpp
M compiler/passes/checkParsed.cpp
M compiler/passes/normalize.cpp
M compiler/resolution/ResolutionCandidate.cpp
M compiler/resolution/functionResolution.cpp
M compiler/resolution/wrappers.cpp
M test/classes/hilde/methodAssignment.chpl
M test/classes/hilde/methodAssignment.good

Compare: Comparing 661aaa074c6f...92b0427a34f5 · chapel-lang/chapel · GitHub