-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Inline traits for specialization in Scala 3 #17329
Draft
timotheeandres
wants to merge
106
commits into
scala:main
Choose a base branch
from
dotty-staging:inline-traits
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
timotheeandres
force-pushed
the
inline-traits
branch
2 times, most recently
from
April 26, 2023 14:37
8395ec0
to
bd493a3
Compare
timotheeandres
force-pushed
the
inline-traits
branch
4 times, most recently
from
May 12, 2023 14:34
8037450
to
f2f4d91
Compare
timotheeandres
force-pushed
the
inline-traits
branch
4 times, most recently
from
May 25, 2023 15:49
218b48c
to
6faa387
Compare
timotheeandres
force-pushed
the
inline-traits
branch
from
June 6, 2023 09:01
e1ef696
to
6c3f4da
Compare
timotheeandres
force-pushed
the
inline-traits
branch
from
June 15, 2023 13:33
340d06b
to
9981eb5
Compare
Inline defs without their bodies, from non-generic inline trait
Inline defs without their bodies, from generic inline trait
By marking the methods to inline inside an inline trait with the BodyAnnotation, we can leverage the current code that inlines bodies To do so, we mark the methods, and let the overriding methods call their super counterpart. The inliner then handles the rest
Allows for private trait parameters and private inner classes
Blacklists inline trait tests from the pickling test, because spans are not working as expected right now... Might be a HUGE pain to deal with now. Please roll me back before merging with main :(
Traits cannot have by-name parameters
This reverts commit 40b7857.
The test for generic inner trait is currently disabled: generic inner traits do not work yet
For some reason, this is not needed anymore (don't know why at all...)
When "transforming" an inner class into an inner trait, we need to adapt its parents as well. When declaring its parents, a trait cannot call their constructor, therefore the different Apply and other trees should be pruned from them. For example: ``` inline trait A: class InnerA extends Object ``` will result in the following code after Inlining: ``` inline trait A: trait InnerA$trait extends Object type InnerA <: InnerA$trait ``` The tree for `Object` in the first case is ``` Apply(Select(New(Ident(Object)),<init>),List()) ``` but if we make InnerA a trait instead, it is simply ``` Ident(Object) ``` The goal is therefore to strip the different "concrete" elements of the parents when transforming a class into a trait.
This way, we have a benchmark test that does not rely on inner classes
timotheeandres
force-pushed
the
inline-traits
branch
from
June 16, 2023 13:08
9981eb5
to
d229aa7
Compare
Non-local private fields can be accessed by other instances of the class. However, this creates the following issue: ``` inline trait A: private val x = 1 def eq(o: A) = o.x == x class B extends A ``` In the code above, when we inline the code into B, `o.x` accesses a private field of A from B, which is not allowed. To allow this, we'd need to either make x protected, or change the signature of `eq` to take a B instead.
The current check allowed the user to override vars, we don't want that Only the compiler should be allowed to do this, and for inline traits only
timotheeandres
force-pushed
the
inline-traits
branch
from
July 4, 2023 08:33
d229aa7
to
a557940
Compare
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.
Master's project on the dotty compiler. The goal is to create a new construct,
inline trait
, that can specialize code in a more space-efficient way than the@specialized
annotation in Scala 2.See https://infoscience.epfl.ch/record/303591?ln=en for more information. Original idea and draft in #15532.