Skip to content

Simplify import of qctx.tasty.rootContext #8438

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

Conversation

nicolasstucki
Copy link
Contributor

Allow rootContext with import qctx.tasty._ (no given import)

This takes advantage of the change introduced in #8410

Allow `rootContext` with `import qctx.tasty._` (no given import)
@nicolasstucki nicolasstucki requested a review from liufengyun March 4, 2020 18:01
@nicolasstucki nicolasstucki self-assigned this Mar 4, 2020
@nicolasstucki nicolasstucki changed the title Simplify import of tasty.rootContext Simplify import of qctx.tasty.rootContext Mar 4, 2020
@nicolasstucki nicolasstucki marked this pull request as ready for review March 4, 2020 18:43
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

@@ -452,7 +452,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
//////////////

/** Context of the macro expansion */
given rootContext as Context = internal.rootContext // TODO: Use given // TODO: Should this be moved to QuoteContext?
def rootContext: Context = internal.rootContext // TODO: Should this be moved to QuoteContext?
given Context = rootContext // TODO: Should be an implicit converion from QuoteContext to Context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems not useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to be able to access the rootContext by name when only importing import qctx.tasty._ , otherwise it is only visible with the given import.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing changed for summoning it

@@ -11,7 +11,7 @@ object SourceFiles {

def getThisFileImpl: Macro[String] = {
val qctx = tastyContext
import qctx.tasty.{_, given _}
import qctx.tasty._
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have many such cases in the test set, change them too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to adapt unseal to be able to change them all

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #8441

@nicolasstucki nicolasstucki merged commit 5c6098f into scala:master Mar 5, 2020
@nicolasstucki nicolasstucki deleted the simplify-import-of-tasty-rootContext branch March 5, 2020 16:35
@anatoliykmetyuk anatoliykmetyuk added this to the 0.23.0-RC1 milestone Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants