@@ -442,9 +442,9 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
442
442
}
443
443
444
444
given TypeToQuotedOps : extension (tpe : Type ) {
445
- /** Convert `Type` to an `quoted.Type[_]` */
446
- def seal (given ctx : Context ): scala.quoted.Type [_] =
447
- internal.QuotedType_seal (tpe)
445
+ /** Convert `Type` to an `quoted.Type[_]` */
446
+ def seal (given ctx : Context ): scala.quoted.Type [_] =
447
+ internal.QuotedType_seal (tpe)
448
448
}
449
449
450
450
// ////////////
@@ -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
- lazy val localCtx : Context = tree .symbol.localContext
2745
+ def localCtx ( definition : Definition ) : Context = definition .symbol.localContext
2746
2746
tree match {
2747
2747
case Ident (_) =>
2748
2748
x
@@ -2785,16 +2785,20 @@ 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
- given Context = localCtx
2788
+ val ctx = localCtx(vdef)
2789
+ given Context = ctx
2789
2790
foldTrees(foldTree(x, tpt), rhs)
2790
2791
case ddef @ DefDef (_, tparams, vparamss, tpt, rhs) =>
2791
- given Context = localCtx
2792
+ val ctx = localCtx(ddef)
2793
+ given Context = ctx
2792
2794
foldTrees(foldTree(vparamss.foldLeft(foldTrees(x, tparams))(foldTrees), tpt), rhs)
2793
2795
case tdef @ TypeDef (_, rhs) =>
2794
- given Context = localCtx
2796
+ val ctx = localCtx(tdef)
2797
+ given Context = ctx
2795
2798
foldTree(x, rhs)
2796
2799
case cdef @ ClassDef (_, constr, parents, derived, self, body) =>
2797
- given Context = localCtx
2800
+ val ctx = localCtx(cdef)
2801
+ given Context = ctx
2798
2802
foldTrees(foldTrees(foldTrees(foldTrees(foldTree(x, constr), parents), derived), self), body)
2799
2803
case Import (expr, _) =>
2800
2804
foldTree(x, expr)
@@ -2862,20 +2866,23 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2862
2866
}
2863
2867
2864
2868
def transformStatement (tree : Statement )(given ctx : Context ): Statement = {
2865
- lazy val localCtx : Context = tree .symbol.localContext
2869
+ def localCtx ( definition : Definition ) : Context = definition .symbol.localContext
2866
2870
tree match {
2867
2871
case tree : Term =>
2868
2872
transformTerm(tree)
2869
2873
case tree : ValDef =>
2870
- given Context = localCtx
2874
+ val ctx = localCtx(tree)
2875
+ given Context = ctx
2871
2876
val tpt1 = transformTypeTree(tree.tpt)
2872
2877
val rhs1 = tree.rhs.map(x => transformTerm(x))
2873
2878
ValDef .copy(tree)(tree.name, tpt1, rhs1)
2874
2879
case tree : DefDef =>
2875
- given Context = localCtx
2880
+ val ctx = localCtx(tree)
2881
+ given Context = ctx
2876
2882
DefDef .copy(tree)(tree.name, transformSubTrees(tree.typeParams), tree.paramss mapConserve (transformSubTrees(_)), transformTypeTree(tree.returnTpt), tree.rhs.map(x => transformTerm(x)))
2877
2883
case tree : TypeDef =>
2878
- given Context = localCtx
2884
+ val ctx = localCtx(tree)
2885
+ given Context = ctx
2879
2886
TypeDef .copy(tree)(tree.name, transformTree(tree.rhs))
2880
2887
case tree : ClassDef =>
2881
2888
ClassDef .copy(tree)(tree.name, tree.constructor, tree.parents, tree.derived, tree.self, tree.body)
0 commit comments