[Chapel Merge] IFC: Invoke required functions through associated

Branch: refs/heads/master
Revision: a8c0c2b
Author: vasslitvinov
Log Message:

Merge pull request #17678 from vasslitvinov/ifc-acons-reqfns

IFC: Invoke required functions through associated constraints

This PR implements support for invoking required functions that are available
due to associated constraints. For example:

interface IFC(Self) {
  type AT;
  AT implements Comparable;
  proc reqFn(arg1: AT, arg2: AT) {
if arg1 == arg2 then ...;      // invokes operator == from Comparable
  }
}

interface Comparable(Self) {
  operator ==(arg1: AT, arg2: AT): bool;
}

IMPLEMENTATION NOTES

  • Modifies the current implementation based on introducing "representatives"
    for required functions to add those for associated constraints as well.
    Introduces recursion in execution and in data structures to handle
    associated constraints of associated constraints etc. In the future
    we will want to switch from introducing representatives to another
    approach that scales well to large interfaces. Arbitrarily cuts recursion
    at the depth of 3.

  • For storing the implementations of associated constraints,
    switches from a map ImplementsStmt::aconsWitnMap
    to a vector ImplementsStmt::witnesses.conWits, storing them in the order
    those constraints are listed in InterfaceSymbol::associatedConstraints

  • Overloads the term "witness" to mean one of:

    • an ImplementsStmt that satisfies the interface constraint at hand
    • the implementation of a required function provided by this ImplementsStmt
    • the instantiation of an associated type provided by this ImplementsStmt

    One potential alternative for the last two is "implementors".

    Correspondingly, we now have these fields

    • ResolutionCandidate::witnessIstms
    • ImplementsStmt::witnesses.symWits
  • More comments.

r: @mppf

Modified Files:
A test/constrained-generics/basic/associated/using-acons-functions.chpl

A test/constrained-generics/basic/associated/using-acons-functions.good
M compiler/AST/FnSymbol.cpp
M compiler/AST/interfaces.cpp
M compiler/include/FnSymbol.h
M compiler/include/ResolutionCandidate.h
M compiler/include/resolution.h
M compiler/include/stmt.h
M compiler/include/symbol.h
M compiler/resolution/ResolutionCandidate.cpp
M compiler/resolution/interfaceResolution.cpp

Compare: https://github.com/chapel-lang/chapel/compare/c7478ed4e391...a8c0c2b1a222