@@ -419,29 +419,29 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
419
419
// QUOTES //
420
420
// //////////////
421
421
422
- implicit class QuotedExprAPI [ T ] (expr : scala.quoted.Expr [T ]) {
422
+ given QuotedExprOps : extension (expr : scala.quoted.Expr [? ]) {
423
423
/** View this expression `quoted.Expr[T]` as a `Term` */
424
424
def unseal (given ctx : Context ): Term =
425
425
internal.QuotedExpr_unseal (expr)
426
426
427
427
/** Checked cast to a `quoted.Expr[U]` */
428
- def cast [U : scala.quoted.Type ]( given ctx : Context ): scala.quoted.Expr [U ] =
428
+ def cast [U ]( given tp : scala.quoted.Type [ U ], ctx : Context ): scala.quoted.Expr [U ] =
429
429
internal.QuotedExpr_cast [U ](expr)
430
430
}
431
431
432
- implicit class QuotedTypeAPI [T <: AnyKind ](tpe : scala.quoted.Type [T ]) {
432
+ given QuotedTypeAPI : extension [T <: AnyKind ](tpe : scala.quoted.Type [T ]) {
433
433
/** View this expression `quoted.Type[T]` as a `TypeTree` */
434
434
def unseal (given ctx : Context ): TypeTree =
435
435
internal.QuotedType_unseal (tpe)
436
436
}
437
437
438
- implicit class TermToQuotedAPI (term : Term ) {
438
+ given TermToQuotedOps : extension (term : Term ) {
439
439
/** Convert `Term` to an `quoted.Expr[Any]` */
440
440
def seal (given ctx : Context ): scala.quoted.Expr [Any ] =
441
441
internal.QuotedExpr_seal (term)
442
442
}
443
443
444
- implicit class TypeToQuotedAPI (tpe : Type ) {
444
+ given TypeToQuotedOps : extension (tpe : Type ) {
445
445
/** Convert `Type` to an `quoted.Type[_]` */
446
446
def seal (given ctx : Context ): scala.quoted.Type [_] =
447
447
internal.QuotedType_seal (tpe)
@@ -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
}
@@ -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
- implicit val ctx = localCtx(vdef)
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
- implicit val ctx = localCtx(ddef)
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
- implicit val ctx = localCtx(tdef)
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
- implicit val ctx = localCtx(cdef)
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)
@@ -2867,15 +2871,18 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2867
2871
case tree : Term =>
2868
2872
transformTerm(tree)
2869
2873
case tree : ValDef =>
2870
- implicit val ctx = localCtx(tree)
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
- implicit val ctx = localCtx(tree)
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
- implicit val ctx = localCtx(tree)
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