Skip to content

Commit

Permalink
dyno: Support non-local receivers and improve resolution of type quer…
Browse files Browse the repository at this point in the history
…ies (#26038)

This PR adds support for non-local receivers to dyno and fixes a bug
affecting the resolution of type queries. It adds support for programs
like the following:

```chapel
    class Foo {
      type T;
      proc get(type t) type do return t;

      proc foo() {
        // Here 'nested' is not a method, but 'this' is still visible as
        // an outer variable. It is a non-local receiver from the
        // parent method 'foo'.
        proc nested(x : get(T)) do return x;
        return nested(0);
      }
    }
```

Refactor the `Resolver::methodReceiverType()` method to make use of a
new method `closestMethodReceiverInfo()`. Remove `getMethodReceiver` and
streamline how receiver information is computed. When resolving, try to
compute a local method receiver using whatever means are available. If
that fails, consult stack frames for the first method that lexically
encloses the current symbol and use its receiver instead.

In `getMethodReceiverScopeHelper()` and friend, flatten out the branches
used to make the function idempotent and to handle `scopeResolveOnly`.
This makes the typed path for setting up the helper easier to digest.

Fix a bug in type query resolution that caused every call to be treated
as though it were a type constructor for a composite type. To do this,
compute if type queries are present in children in
`Resolver::resolveTypeQueries` and do nothing if they are not. Secondly,
rely on the `Resolver::signatureOnly` flag to avoid emitting errors
unless we are resolving a signature and have access to the types of
sub-expressions.

Reviewed by @mppf. Thanks!
  • Loading branch information
dlongnecke-cray authored Oct 31, 2024
2 parents 1cbb933 + d39f2ed commit 07d6adc
Show file tree
Hide file tree
Showing 5 changed files with 441 additions and 244 deletions.
Loading

0 comments on commit 07d6adc

Please sign in to comment.