-
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
Enable returning classes from MacroAnnotations (part 3) #16534
Merged
smarter
merged 13 commits into
scala:main
from
dotty-staging:macro-annotations-add-class
Jan 12, 2023
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0dcf795
Enable returning classes from MacroAnnotations (part 3)
nicolasstucki 5fcb869
Add reflect `Symbol.newModule`
nicolasstucki 079a786
Update MacroAnnotation documentation
nicolasstucki a3ce771
Fix typos
nicolasstucki ac239fd
Use ModuleValCreationFlags and ModuleClassCreationFlags
nicolasstucki 89c550b
Add test for top level classes added from defs in nested packages
nicolasstucki 8c30d37
Add generated classes at the end of the package
nicolasstucki 429103e
Remove IdentityDenotTransformer from MacroTransform
nicolasstucki 9f4042a
Implement newNormalizedModuleSymbol
nicolasstucki 1acd745
Add reflect ClassDef.module
nicolasstucki ecba50d
Apply suggestions from code review
nicolasstucki 41a46fc
Improve doc
nicolasstucki 6c6dc77
Handle top-level class insertion using a MutableSymbolMap
nicolasstucki 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
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
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.
Unfortunately I think this isn't sufficient because package objects can be nested:
Instead, maybe the MemberDef case of transform should return a Thicket with the top-level classes, and we should add an extra case to
transform
to handle the package object module class itself, where we should also return a Thicket with the top-level classesThere 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.
This use case was considered and works. I added tests for it in
tests/run-macros/annot-add-global-class
.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 that after after post typer the tree is
This implies that nested classes are processed first and the buffer never overlaps and is emptied just after transforming the nested package.
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.
This is subtle, so this precondition should be documented in the code (and ideally checked somewhere, in case it breaks)
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 found cases where this precondition does not hold. I updated the implementation to handle such cases.