[Chapel Merge] dyno: fix up generic types passed as type argument

Branch: refs/heads/main
Revision: 287940a
Author: mppf
Link: dyno: fix up generic types passed as type arguments by mppf · Pull Request #19320 · chapel-lang/chapel · GitHub
Log Message:

Merge pull request #19320 from mppf/dyno-puzzle

dyno: fix up generic types passed as type arguments

This PR adjusts the dyno resolver to function when a generic type is
passed as a type argument.

These changes are motivated by getting the following example working. The
example is added as a test.

proc useType(type t) {
  var ret: t(1);
  return ret;
}
record R {
  param p;
}
var x = useType(R);

Details:

  • adds calledType to the CallInfo.
  • adds a little visitor to gather fields or formals from a Decl (since
    a field might be a MultiDecl or TupleDecl)
  • struct Resolver now keeps track of which IDs are fields/formals
    and which are instantiated fields/formals (to resolve the problem
    with passing a generic type as a type argument). These are
    computed as needed if/when shouldUseUnknownTypeForGeneric is called.
  • migrated the struct Resolver constructors to static functions with
    a name that communicates the purpose.

Future Work:

  • When creating a TypedFnSignature for initial resolution of a generic
    function, UnknownType is used for things that depend on an
    instantiated type (e.g. in proc f(a, b: a.type), b will have
    UnknownType in the initial TypedFnSignature. However this is not
    tested directly yet and we would like to add testing for it.

    Modified Files:
    M compiler/dyno/include/chpl/resolution/resolution-types.h
    M compiler/dyno/lib/resolution/resolution-queries.cpp
    M compiler/dyno/test/resolution/testTypeConstruction.cpp

    Compare: Comparing 57bd7d95c5e1...287940a91be0 · chapel-lang/chapel · GitHub