@@ -452,7 +452,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
452
452
// ////////////
453
453
454
454
/** Context of the macro expansion */
455
- implicit def rootContext : Context = internal.rootContext // TODO: Use given // TODO: Should this be moved to QuoteContext?
455
+ given rootContext : Context = internal.rootContext // TODO: Use given // TODO: Should this be moved to QuoteContext?
456
456
457
457
given ContextOps : extension (self : Context ) {
458
458
/** Returns the owner of the context */
@@ -1009,7 +1009,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
1009
1009
case _ => None
1010
1010
}
1011
1011
1012
- def apply (tpe : MethodType , rhsFn : List [Tree ] => Tree )(implicit ctx : Context ): Block =
1012
+ def apply (tpe : MethodType , rhsFn : List [Tree ] => Tree )(given ctx : Context ): Block =
1013
1013
internal.Lambda_apply (tpe, rhsFn)
1014
1014
1015
1015
}
@@ -2742,7 +2742,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2742
2742
def foldTrees (x : X , trees : Iterable [Tree ])(given ctx : Context ): X = trees.foldLeft(x)(foldTree)
2743
2743
2744
2744
def foldOverTree (x : X , tree : Tree )(given ctx : Context ): X = {
2745
- def localCtx ( definition : Definition ) : Context = definition .symbol.localContext
2745
+ lazy val localCtx : Context = tree .symbol.localContext
2746
2746
tree match {
2747
2747
case Ident (_) =>
2748
2748
x
@@ -2785,16 +2785,16 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2785
2785
case Inlined (call, bindings, expansion) =>
2786
2786
foldTree(foldTrees(x, bindings), expansion)
2787
2787
case vdef @ ValDef (_, tpt, rhs) =>
2788
- implicit val ctx = localCtx(vdef)
2788
+ given Context = localCtx
2789
2789
foldTrees(foldTree(x, tpt), rhs)
2790
2790
case ddef @ DefDef (_, tparams, vparamss, tpt, rhs) =>
2791
- implicit val ctx = localCtx(ddef)
2791
+ given Context = localCtx
2792
2792
foldTrees(foldTree(vparamss.foldLeft(foldTrees(x, tparams))(foldTrees), tpt), rhs)
2793
2793
case tdef @ TypeDef (_, rhs) =>
2794
- implicit val ctx = localCtx(tdef)
2794
+ given Context = localCtx
2795
2795
foldTree(x, rhs)
2796
2796
case cdef @ ClassDef (_, constr, parents, derived, self, body) =>
2797
- implicit val ctx = localCtx(cdef)
2797
+ given Context = localCtx
2798
2798
foldTrees(foldTrees(foldTrees(foldTrees(foldTree(x, constr), parents), derived), self), body)
2799
2799
case Import (expr, _) =>
2800
2800
foldTree(x, expr)
@@ -2862,20 +2862,20 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2862
2862
}
2863
2863
2864
2864
def transformStatement (tree : Statement )(given ctx : Context ): Statement = {
2865
- def localCtx ( definition : Definition ) : Context = definition .symbol.localContext
2865
+ lazy val localCtx : Context = tree .symbol.localContext
2866
2866
tree match {
2867
2867
case tree : Term =>
2868
2868
transformTerm(tree)
2869
2869
case tree : ValDef =>
2870
- implicit val ctx = localCtx(tree)
2870
+ given Context = localCtx
2871
2871
val tpt1 = transformTypeTree(tree.tpt)
2872
2872
val rhs1 = tree.rhs.map(x => transformTerm(x))
2873
2873
ValDef .copy(tree)(tree.name, tpt1, rhs1)
2874
2874
case tree : DefDef =>
2875
- implicit val ctx = localCtx(tree)
2875
+ given Context = localCtx
2876
2876
DefDef .copy(tree)(tree.name, transformSubTrees(tree.typeParams), tree.paramss mapConserve (transformSubTrees(_)), transformTypeTree(tree.returnTpt), tree.rhs.map(x => transformTerm(x)))
2877
2877
case tree : TypeDef =>
2878
- implicit val ctx = localCtx(tree)
2878
+ given Context = localCtx
2879
2879
TypeDef .copy(tree)(tree.name, transformTree(tree.rhs))
2880
2880
case tree : ClassDef =>
2881
2881
ClassDef .copy(tree)(tree.name, tree.constructor, tree.parents, tree.derived, tree.self, tree.body)
0 commit comments