-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add requiredXYZ symbols to TASTy reflect context #7903
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
nicolasstucki
merged 5 commits into
scala:master
from
dotty-staging:add-required-symbols-to-tasty-reflect
Jan 7, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
953479a
Add requiredXYZ symbols to TASTy reflect context
nicolasstucki fea0dd6
Refactor some conditions
nicolasstucki 120c033
Remove useless extractors
nicolasstucki ac7c395
Remove useless extractors
nicolasstucki 811804d
Add tests
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 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
java | ||
java.lang | ||
scala | ||
scala.collection | ||
java.lang.Object | ||
scala.Any | ||
scala.Any | ||
scala.AnyVal | ||
scala.Unit | ||
scala.Null | ||
scala.None | ||
scala.package$.Nil | ||
scala.collection.immutable.List$.empty |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import scala.quoted._ | ||
|
||
object Macro { | ||
inline def foo: String = ${ fooImpl } | ||
def fooImpl(given qctx: QuoteContext): Expr[String] = { | ||
import qctx.tasty.{given, _} | ||
val list = List( | ||
rootContext.requiredPackage("java"), | ||
rootContext.requiredPackage("java.lang"), | ||
rootContext.requiredPackage("scala"), | ||
rootContext.requiredPackage("scala.collection"), | ||
|
||
rootContext.requiredClass("java.lang.Object"), | ||
rootContext.requiredClass("scala.Any"), | ||
rootContext.requiredClass("scala.AnyRef"), | ||
rootContext.requiredClass("scala.AnyVal"), | ||
rootContext.requiredClass("scala.Unit"), | ||
rootContext.requiredClass("scala.Null"), | ||
|
||
rootContext.requiredModule("scala.None"), | ||
rootContext.requiredModule("scala.Nil"), | ||
|
||
rootContext.requiredMethod("scala.List.empty"), | ||
) | ||
Expr(list.map(_.fullName).mkString("\n")) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
println(Macro.foo) | ||
} | ||
} |
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.
The meta-programmer may not know what's a module. Maybe rename to
requiredObject
?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.
Better to keep names consistent. It will be simpler for documentation. We also have
moduleClass
andcompanionModule
that use the same naming scheme.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 totally agree, for advanced meta-programming, keeping the concepts closer to the compiler will help both meta-programmers who want to get into the compiler and maintenance of the framework.