Skip to content

Allow resolving any identifier to its declaration in the definitions phase (phase 3) #3216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jakemac53 opened this issue Jul 14, 2023 · 1 comment
Assignees
Labels
static-metaprogramming Issues related to static metaprogramming

Comments

@jakemac53
Copy link
Contributor

We already allow this for type declarations (in phase 2 & 3), but don't have an API for other declarations. We will likely want to either change the return type of the existing declarationOf API in phase 3 to be just Declaration, or we will want to rename it to typeDeclarationOf and then add a new declarationOf API for phase 3.

See #1930 (comment), previously this wasn't really necessary for anything because there was not really any way to get an identifier for anything other than a type except for from the declaration itself (so you already had access to it). But with metadata annotations, you will want to be able to go look at the identifiers.

Another possible approach could be to just force you to evaluate the identifier, and then expose the type of it through the returned object.

@jakemac53
Copy link
Contributor Author

This is out for review, https://dart-review.googlesource.com/c/sdk/+/314280

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jul 19, 2023
- Rename declarationOf to typeDeclarationOf.
- Add declarationOf api for general declarations.
- Tighten the type of typeDeclarationOf in the final phase to avoid unnecessary
  casts in user code.
- Refactor message handling a bit to unify the error handling.

Bug: dart-lang/language#3216
Change-Id: Ia61da19374abec77853d37e110a08f7dfe0d3b10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314280
Commit-Queue: Jake Macdonald <[email protected]>
Auto-Submit: Jake Macdonald <[email protected]>
Reviewed-by: Bob Nystrom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
static-metaprogramming Issues related to static metaprogramming
Projects
Development

No branches or pull requests

1 participant