Add domain subfield access operation#5238
Merged
Merged
Conversation
bd7c41c to
a72f912
Compare
4ede800 to
10e0e94
Compare
jackkoenig
approved these changes
Mar 19, 2026
jackkoenig
left a comment
Contributor
There was a problem hiding this comment.
I think we will eventually want to replace this with a type-safe dynamic (using a macro), but I think this is fine for the type being.
We should do that more type-safe version in Scala 3 only once the macro comes online for D/I--but that will also require changes to the Domain API so that's something to consider (hard to do with fields being a Seq[(String, Field.Type)].
Add a new API for doing static subfield accesses of domain fields. E.g., allow `A.field.name` where `A` is a domain and "name" is a field of the domain. The `field` method provides one level of indirection to avoid name collisions with anything on `Element`, which properties extend. This opts to use Scala's `Dynamic` [[1]] which allows for dynamic invocation. This removes some type safety, as illegal accesses are discovered at runtime as opposed to at compile time. However, this is generally a much cleaner approach compared to alternatives (macros, compiler plugins, etc.) that requires no porting to Scala 3. [1]: https://www.scala-lang.org/api/current/scala/Dynamic.html Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
10e0e94 to
4988152
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change enables accessing fields of domain ports using dynamic
selection:(e.g.,
A.namewhereAis a domain type andnameis a fieldof that domain). The field access returns a
Propertyof the appropriatetype based on the field's type in the domain schema.
AI-assisted-by: Augment (Claude Sonnet 4.5)
Release Notes
Add domain subfield operation to allow the reading of a domain field as a
property.