Skip to content

Commit 1c73259

Browse files
committed
Use asReflectTree
1 parent 1180aba commit 1c73259

File tree

89 files changed

+156
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+156
-159
lines changed

library/src-bootstrapped/scala/quoted/Const.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object Const {
2323
case Inlined(_, Nil, e) => rec(e)
2424
case _ => None
2525
}
26-
rec(expr.unseal)
26+
rec(expr.asReflectTree)
2727
}
2828

2929
}

library/src-bootstrapped/scala/quoted/Expr.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Expr {
1414
* Some bindings may be elided as an early optimization.
1515
*/
1616
def betaReduce[T](expr: Expr[T])(using qctx: QuoteContext): Expr[T] =
17-
qctx.reflect.Term.betaReduce(expr.unseal) match
17+
qctx.reflect.Term.betaReduce(expr.asReflectTree) match
1818
case Some(expr1) => expr1.asExpr.asInstanceOf[Expr[T]]
1919
case _ => expr
2020

@@ -24,7 +24,7 @@ object Expr {
2424
*/
2525
def block[T](statements: List[Expr[Any]], expr: Expr[T])(using qctx: QuoteContext): Expr[T] = {
2626
import qctx.reflect._
27-
Block(statements.map(_.unseal), expr.unseal).asExpr.asInstanceOf[Expr[T]]
27+
Block(statements.map(_.asReflectTree), expr.asReflectTree).asExpr.asInstanceOf[Expr[T]]
2828
}
2929

3030
/** Lift a value into an expression containing the construction of that value */

library/src-bootstrapped/scala/quoted/ExprMap.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ trait ExprMap:
104104
type X
105105
val expr = tree.asExpr.asInstanceOf[Expr[X]]
106106
val t = tpe.asType.asInstanceOf[Type[X]]
107-
transform(expr)(using qctx, t).unseal
107+
transform(expr)(using qctx, t).asReflectTree
108108
case _ =>
109109
transformTermChildren(tree, tpe)
110110

@@ -144,7 +144,7 @@ trait ExprMap:
144144
trees mapConserve (transformTypeCaseDef(_))
145145

146146
}
147-
new MapChildren().transformTermChildren(e.unseal, TypeRepr.of[T]).asExprOf[T]
147+
new MapChildren().transformTermChildren(e.asReflectTree, TypeRepr.of[T]).asExprOf[T]
148148
}
149149

150150
end ExprMap

library/src-bootstrapped/scala/quoted/Varargs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Varargs {
1717
*/
1818
def apply[T](xs: Seq[Expr[T]])(using tp: Type[T], qctx: QuoteContext): Expr[Seq[T]] = {
1919
import qctx.reflect._
20-
Repeated(xs.map[Term](_.unseal).toList, TypeTree.of[T]).asExpr.asInstanceOf[Expr[Seq[T]]]
20+
Repeated(xs.map[Term](_.asReflectTree).toList, TypeTree.of[T]).asExpr.asInstanceOf[Expr[Seq[T]]]
2121
}
2222

2323
/** Matches a literal sequence of expressions and return a sequence of expressions.
@@ -40,7 +40,7 @@ object Varargs {
4040
case Inlined(_, Nil, e) => rec(e)
4141
case _ => None
4242
}
43-
rec(expr.unseal)
43+
rec(expr.asReflectTree)
4444
}
4545

4646
}

library/src/scala/quoted/QuoteContext.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ trait QuoteContext { self: internal.QuoteUnpickler & internal.QuoteMatching =>
4747
report.throwError(msg, self)(using QuoteContext.this)
4848
unlift.fromExpr(self)(using QuoteContext.this).getOrElse(reportError)
4949

50-
/** View this expression `quoted.Expr[T]` as a `Term` */
51-
def unseal: reflect.Term = self.asReflectTree // TODO remove
52-
5350
/** View this expression `quoted.Expr[T]` as a `Term` */
5451
def asReflectTree: reflect.Term
5552
end extension

library/src/scala/quoted/report.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object report:
88

99
/** Report an error at the on the position of `expr` */
1010
def error(msg: => String, expr: Expr[Any])(using qctx: QuoteContext): Unit =
11-
qctx.reflect.Reporting.error(msg, expr.unseal.pos)
11+
qctx.reflect.Reporting.error(msg, expr.asReflectTree.pos)
1212

1313
/** Report an error at the position of the macro expansion and throws a StopQuotedContext */
1414
def throwError(msg: => String)(using qctx: QuoteContext): Nothing = {
@@ -27,7 +27,7 @@ object report:
2727

2828
/** Report a warning at the on the position of `expr` */
2929
def warning(msg: => String, expr: Expr[_])(using qctx: QuoteContext): Unit =
30-
qctx.reflect.Reporting.warning(msg, expr.unseal.pos)
30+
qctx.reflect.Reporting.warning(msg, expr.asReflectTree.pos)
3131

3232
/** Throwable used to stop the expansion of a macro after an error was reported */
3333
class StopQuotedContext extends Throwable

tests/neg-macros/i6432/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Macro {
1010
sc match {
1111
case '{ StringContext(${Varargs(parts)}: _*) } =>
1212
for (part @ Const(s) <- parts)
13-
Reporting.error(s, part.unseal.pos)
13+
Reporting.error(s, part.asReflectTree.pos)
1414
}
1515
'{}
1616
}

tests/neg-macros/i6432b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Macro {
1010
sc match {
1111
case '{ StringContext(${Varargs(parts)}: _*) } =>
1212
for (part @ Const(s) <- parts)
13-
Reporting.error(s, part.unseal.pos)
13+
Reporting.error(s, part.asReflectTree.pos)
1414
}
1515
'{}
1616
}

tests/neg-macros/i6976/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ object macros {
77

88
def mcrImpl(body: Expr[Any])(using ctx: QuoteContext) : Expr[Any] = {
99
import ctx.reflect._
10-
body.unseal match { case Block(_, _) => '{2} }
10+
body.asReflectTree match { case Block(_, _) => '{2} }
1111
}
1212
}

tests/neg-macros/i7698.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ trait Show[T] {
55
}
66

77
def showInterpolatorImpl(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext): Expr[String] =
8-
argsExpr.unseal match
8+
argsExpr.asReflectTree match
99
case '{ $arg: $t } => // error
1010
case '[ Int ] => // error
1111
???

0 commit comments

Comments
 (0)