Inline Traits & Specialized Traits#26156
Draft
starswap wants to merge 325 commits into
Draft
Conversation
…s from the parent traits later so they need to live in the children
… the bodies of methods defined inside inline traits
78aec78 to
afd9b33
Compare
…t just ordering change)
Opaque types can appear in inline traits. This is not the case for inline methods, so we run into the new case that a LazyBodyAnnotation contains an inline trait. This causes a problem because the LazyBodyAnnotation and the ordinary code both complete the opaque type's LazyRefs which causes us to throw a CyclicReference. It turns out that this CyclicReference throw was originally created for a test case which we no longer reject (typer evolved and we now accept tests/pos/i9052. Therefore we conclude that this CyclicReference is no longer really needed. Removing it allows us to support opaque types in inline traits but it does change the error behaviour of two other tests (modified in this commit). I claim that the resulting errors are acceptable for both of these cases. In particular, the issues they correspond to were both crashes, and we still don't crash without the cyclic reference error. The errors we throw are modified but I think reasonable; feel free to check for yourself.
starswap
commented
Jun 7, 2026
|
|
||
| // Because opaque types can appear in inline traits and these are only allowed to be completed once (otherwise cyclic reference error) | ||
| // we need to force the body stats now if we have an inline trait so that we don't complete them twice, once in the LazyBodyAnnot and once | ||
| // in the main code. |
Contributor
Author
There was a problem hiding this comment.
Check: Is this ok? I'm not sure if we can do this because maybe it is actually necessary to read the contents of the body annotation in the context of the body annotation. It seems to pass tests but I'm not sure if it's ok. Also this code was copied from the inline methods case so it is possible not all of it is needed for inline traits.
…ng cross platform
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.
Final year master's project at EPFL. Introduces specialization for Scala 3 as an experimental feature, via:
The latest specification for each of these is included in docs accompanying the PR. To see a demo of the generated code and speed gain offered, try
tools/benchmarks/SpecializedTraitsBenchmark.scalaHow much have you relied on LLM-based tools in this contribution?
Moderately, for debugging.
How was the solution tested?
New automated tests