Skip to content

Commit a04c9c4

Browse files
committed
Address review comments
1 parent e8206d7 commit a04c9c4

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

library/src/scala/tasty/Reflection.scala

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
442442
}
443443

444444
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)
448448
}
449449

450450
//////////////
@@ -2742,7 +2742,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
27422742
def foldTrees(x: X, trees: Iterable[Tree])(given ctx: Context): X = trees.foldLeft(x)(foldTree)
27432743

27442744
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
27462746
tree match {
27472747
case Ident(_) =>
27482748
x
@@ -2785,16 +2785,20 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
27852785
case Inlined(call, bindings, expansion) =>
27862786
foldTree(foldTrees(x, bindings), expansion)
27872787
case vdef @ ValDef(_, tpt, rhs) =>
2788-
given Context = localCtx
2788+
val ctx = localCtx(vdef)
2789+
given Context = ctx
27892790
foldTrees(foldTree(x, tpt), rhs)
27902791
case ddef @ DefDef(_, tparams, vparamss, tpt, rhs) =>
2791-
given Context = localCtx
2792+
val ctx = localCtx(ddef)
2793+
given Context = ctx
27922794
foldTrees(foldTree(vparamss.foldLeft(foldTrees(x, tparams))(foldTrees), tpt), rhs)
27932795
case tdef @ TypeDef(_, rhs) =>
2794-
given Context = localCtx
2796+
val ctx = localCtx(tdef)
2797+
given Context = ctx
27952798
foldTree(x, rhs)
27962799
case cdef @ ClassDef(_, constr, parents, derived, self, body) =>
2797-
given Context = localCtx
2800+
val ctx = localCtx(cdef)
2801+
given Context = ctx
27982802
foldTrees(foldTrees(foldTrees(foldTrees(foldTree(x, constr), parents), derived), self), body)
27992803
case Import(expr, _) =>
28002804
foldTree(x, expr)
@@ -2862,20 +2866,23 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
28622866
}
28632867

28642868
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
28662870
tree match {
28672871
case tree: Term =>
28682872
transformTerm(tree)
28692873
case tree: ValDef =>
2870-
given Context = localCtx
2874+
val ctx = localCtx(tree)
2875+
given Context = ctx
28712876
val tpt1 = transformTypeTree(tree.tpt)
28722877
val rhs1 = tree.rhs.map(x => transformTerm(x))
28732878
ValDef.copy(tree)(tree.name, tpt1, rhs1)
28742879
case tree: DefDef =>
2875-
given Context = localCtx
2880+
val ctx = localCtx(tree)
2881+
given Context = ctx
28762882
DefDef.copy(tree)(tree.name, transformSubTrees(tree.typeParams), tree.paramss mapConserve (transformSubTrees(_)), transformTypeTree(tree.returnTpt), tree.rhs.map(x => transformTerm(x)))
28772883
case tree: TypeDef =>
2878-
given Context = localCtx
2884+
val ctx = localCtx(tree)
2885+
given Context = ctx
28792886
TypeDef.copy(tree)(tree.name, transformTree(tree.rhs))
28802887
case tree: ClassDef =>
28812888
ClassDef.copy(tree)(tree.name, tree.constructor, tree.parents, tree.derived, tree.self, tree.body)

0 commit comments

Comments
 (0)