Skip to content

Commit b302842

Browse files
committed
Simplify import of tasty.rootContext
Allow `rootContext` with `import qctx.tasty._` (no given import)
1 parent 0f09be3 commit b302842

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

library/src/scala/tasty/Reflection.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
452452
//////////////
453453

454454
/** Context of the macro expansion */
455-
given rootContext as Context = internal.rootContext // TODO: Use given // TODO: Should this be moved to QuoteContext?
455+
def rootContext: Context = internal.rootContext // TODO: Should this be moved to QuoteContext?
456+
given Context = rootContext // TODO: Should be an implicit converion from QuoteContext to Context
456457

457458
extension ContextOps on (self: Context) {
458459
/** Returns the owner of the context */

tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object SourceFiles {
1111

1212
def getThisFileImpl: Macro[String] = {
1313
val qctx = tastyContext
14-
import qctx.tasty.{_, given _}
14+
import qctx.tasty._
1515
rootContext.source.getFileName.toString
1616
}
1717

tests/run-macros/tasty-getfile/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ object SourceFiles {
88
${getThisFileImpl}
99

1010
private def getThisFileImpl(using qctx: QuoteContext) : Expr[String] = {
11-
import qctx.tasty.{_, given _}
12-
rootContext.source.getFileName.toString
11+
import qctx.tasty._
12+
summon[Context].source.getFileName.toString
1313
}
1414

1515
}

0 commit comments

Comments
 (0)