-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Multiple fixes to @static #1226
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
2e5ab54
Fix #1220. Dont die when having incorect static methods
DarkDimius 7408f14
Test #1220
DarkDimius bbd48d3
SymDenotations: Allow entering Static symbols.
DarkDimius 806a029
Constructors: do not lift static val initialisation into constructors.
DarkDimius db6a07d
Getters: do not generate getters for static vals
DarkDimius 4ce8ab0
Allow creating static initialisers.
DarkDimius 27846bb
MoveStatic: Move static methods & fields into companion class
DarkDimius 63eb88d
Drop support for @static lazy vals.
DarkDimius ce2b964
Fix type in SymDenotations.
DarkDimius 7cacd0f
Fix #1224: static members do not override\implement parent symbols.
DarkDimius 1932b17
Test #1224.
DarkDimius f650b1e
LazyVals: do not share offsets between companions.
DarkDimius 61fe99b
MoveStatics: fix two bugs.
DarkDimius d9702d2
Fix Ycheck: allow assigning fields in static constructors.
DarkDimius e1fcb4c
LazyVals: support debug mode.
DarkDimius 990e962
SymDenotations: fix comment.
DarkDimius f2cfac5
MoveStatics: survive absence of companions.
DarkDimius fa6deee
DottyBackendInterface: fix a bug in methodSymbols.
DarkDimius 5f73175
Add tests that were used to reproduce issues with LazyVals.
DarkDimius 49ace48
MoveStatics: fix a bug.
DarkDimius 2c6a9be
CheckStatic: report error position in case of disallowed override
DarkDimius 9899a06
LazyVals: fix leftover moduleClass usage.
DarkDimius c428e74
LazyVals: do even more verbose debugging.
DarkDimius de45fa1
MoveStatics: Fix classes without companion not getting static <clinit>
DarkDimius 3c93c5c
Make class initialisers private. Otherwise they break GenBCode.
DarkDimius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
MoveStatics: fix two bugs.
Unlink the static from the old scope, and don't drop top-level trees that are not TypeDefs.
- Loading branch information
commit 61fe99b6ad0fcd0a8402435cf15c504ce4b9c4ea
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ class MoveStatics extends MiniPhaseTransform with SymTransformer { thisTransform | |
|
||
def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = { | ||
if (sym.hasAnnotation(defn.ScalaStaticAnnot) && sym.owner.is(Flags.Module)) { | ||
sym.owner.asClass.delete(sym.symbol) | ||
sym.owner.companionClass.asClass.enter(sym.symbol) | ||
val flags = if (sym.is(Flags.Method)) sym.flags else sym.flags | Flags.Mutable | ||
sym.copySymDenotation(owner = sym.owner.companionClass, initFlags = flags) | ||
|
@@ -58,7 +59,7 @@ class MoveStatics extends MiniPhaseTransform with SymTransformer { thisTransform | |
yield | ||
if (classes.tail.isEmpty) classes.head | ||
else move(classes.head, classes.tail.head) | ||
Trees.flatten(newPairs.toList) | ||
Trees.flatten(newPairs.toList ++ others) | ||
} else trees | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe invert the condition and move this case up -- makes it easier to follow |
||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to remove / unlink the symbol from the module's scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of intentionally not doing so.
To make sure it can be found in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i don't know if that's a good idea (literally - maybe it is..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note here we're already near the backend, so I'm preparing the tree specifically for GenBCode.
Phases that go in this block are backend-specific and break some assumptions of compiler.
Eg
LabelDefs
reorders<label> def
s in a magical order that no one should touch.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's related to exactly that discussion: the current PR creates a static field in both
T
andT$
the one in the module class is not initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ :)