Skip to content

Commit 8844bfe

Browse files
committed
Use asReflectTree
1 parent 1180aba commit 8844bfe

File tree

96 files changed

+163
-166
lines changed

Some content is hidden

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

96 files changed

+163
-166
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
???

tests/neg-macros/i9801/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ def impl(prog: Expr[Double])(using QuoteContext) : Expr[Double] =
1515
triggerStackOverflow(0)
1616
} catch {
1717
case e =>
18-
qctx.reflect.Reporting.error(e.getMessage, prog.unseal.pos)
18+
qctx.reflect.Reporting.error(e.getMessage, prog.asReflectTree.pos)
1919
'{ 42.0 }
2020
}

tests/neg-macros/tasty-macro-assert-1/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object Asserts {
1515
def impl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = {
1616
import qctx.reflect._
1717

18-
val tree = cond.unseal
18+
val tree = cond.asReflectTree
1919

2020
def isOps(tpe: TypeRepr): Boolean = tpe match {
2121
case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts

tests/neg-macros/tasty-macro-assert-2/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object Asserts {
1515
def impl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = {
1616
import qctx.reflect._
1717

18-
val tree = cond.unseal
18+
val tree = cond.asReflectTree
1919

2020
def isOps(tpe: TypeRepr): Boolean = tpe match {
2121
case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts

tests/neg-macros/tasty-macro-error/quoted_1.scala

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

77
def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = {
88
import qctx.reflect._
9-
Reporting.error("here is the the argument is " + x.unseal.underlyingArgument.show, x.unseal.underlyingArgument.pos)
9+
Reporting.error("here is the the argument is " + x.asReflectTree.underlyingArgument.show, x.asReflectTree.underlyingArgument.pos)
1010
'{}
1111
}
1212

tests/neg-macros/tasty-macro-positions/quoted_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ object Macros {
66

77
def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = {
88
import qctx.reflect._
9-
val pos = x.unseal.underlyingArgument.pos
10-
Reporting.error("here is the the argument is " + x.unseal.underlyingArgument.show, pos)
11-
Reporting.error("here (+5) is the the argument is " + x.unseal.underlyingArgument.show, pos.sourceFile, pos.start + 5, pos.end + 5)
9+
val pos = x.asReflectTree.underlyingArgument.pos
10+
Reporting.error("here is the the argument is " + x.asReflectTree.underlyingArgument.show, pos)
11+
Reporting.error("here (+5) is the the argument is " + x.asReflectTree.underlyingArgument.show, pos.sourceFile, pos.start + 5, pos.end + 5)
1212
'{}
1313
}
1414

tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object FIntepolator {
1111

1212
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = {
1313
import qctx.reflect._
14-
Reporting.error("there are no parts", strCtxExpr.unseal.underlyingArgument.pos)
14+
Reporting.error("there are no parts", strCtxExpr.asReflectTree.underlyingArgument.pos)
1515
'{ ($strCtxExpr).s($argsExpr: _*) }
1616
}
1717

tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Macro {
1010
object FIntepolator {
1111
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = {
1212
import qctx.reflect._
13-
Reporting.error("there are no args", argsExpr.unseal.underlyingArgument.pos)
13+
Reporting.error("there are no args", argsExpr.asReflectTree.underlyingArgument.pos)
1414
'{ ($strCtxExpr).s($argsExpr: _*) }
1515
}
1616

tests/neg-staging/i5941/macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ object Lens {
1717
import util._
1818
// obj.copy(field = value)
1919
def setterBody(obj: Expr[S], value: Expr[T], field: String): Expr[S] =
20-
Select.overloaded(obj.unseal, "copy", Nil, NamedArg(field, value.unseal) :: Nil, TypeBounds.empty).asExprOf[S]
20+
Select.overloaded(obj.asReflectTree, "copy", Nil, NamedArg(field, value.asReflectTree) :: Nil, TypeBounds.empty).asExprOf[S]
2121

22-
// exception: getter.unseal.underlyingArgument
23-
getter.unseal match {
22+
// exception: getter.asReflectTree.underlyingArgument
23+
getter.asReflectTree match {
2424
case Inlined(
2525
None, Nil,
2626
Block(

tests/pending/run/tasty-comments/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Macros {
99
def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = {
1010
import qctx.reflect._
1111

12-
val tree = x.unseal
12+
val tree = x.asReflectTree
1313
tree.symbol.comment.map(_.raw) match {
1414
case Some(str) => '{ println(${str}) }
1515
case None => '{ println() }

tests/pos-macros/i6171/Macro_1.scala

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

77
def assertImpl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = {
88
import qctx.reflect._
9-
x.unseal.underlyingArgument
9+
x.asReflectTree.underlyingArgument
1010
'{ () }
1111
}
1212
}

tests/pos-macros/i6535/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object scalatest {
99
import util._
1010
import ValDef.let
1111

12-
cond.unseal.underlyingArgument match {
12+
cond.asReflectTree.underlyingArgument match {
1313
case t @ Apply(Select(lhs, op), rhs :: Nil) =>
1414
let(lhs) { left =>
1515
let(rhs) { right =>
@@ -19,7 +19,7 @@ object scalatest {
1919
val r = right.asExpr
2020
val b = result.asExprOf[Boolean]
2121
val code = '{ scala.Predef.assert($b) }
22-
code.unseal
22+
code.asReflectTree
2323
}
2424
}
2525
}.asExprOf[Unit]

tests/pos-macros/i7011/Macros_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def mcr(body: => Any): Unit = ${mcrImpl('body)}
55
def mcrImpl[T](body: Expr[Any])(using QuoteContext) : Expr[Any] = {
66
import qctx.reflect._
77

8-
val bTree = body.unseal
8+
val bTree = body.asReflectTree
99
val under = bTree.underlyingArgument
1010

1111
val res = '{Box(${under.asInstanceOf[Term].asExpr})}

tests/pos-macros/i7030/Macros_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ def innerImpl(exprs: Expr[Any])(using QuoteContext): Expr[Any] =
77
inline def outer(expr: => Any): Any = ${outerImpl('expr)}
88
def outerImpl(body: Expr[Any])(using QuoteContext): Expr[Any] = {
99
import qctx.reflect._
10-
body.unseal.underlyingArgument.asExpr
10+
body.asReflectTree.underlyingArgument.asExpr
1111
}

tests/pos-macros/i8325/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object A:
1313

1414
def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = {
1515
import qctx.reflect._
16-
expr.unseal match {
16+
expr.asReflectTree match {
1717
case Inlined(x,y,z) => transformImplExpr(z.asExpr.asInstanceOf[Expr[A]])
1818
case Apply(fun,args) => '{ A.pure(${Apply(fun,args).asExpr.asInstanceOf[Expr[A]]}) }
1919
case other => expr

tests/pos-macros/i8325b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object A:
1313

1414
def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = {
1515
import qctx.reflect._
16-
expr.unseal match {
16+
expr.asReflectTree match {
1717
case Inlined(x,y,z) => transformImplExpr(z.asExpr.asInstanceOf[Expr[A]])
1818
case r@Apply(fun,args) => '{
1919
A.pure(${r.asExpr.asInstanceOf[Expr[A]]}) }

tests/pos-macros/i8866/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Macro {
1616

1717
ValDef.let(
1818
Select.unique(
19-
'{ OtherMacro }.unseal,
19+
'{ OtherMacro }.asReflectTree,
2020
"apply"
2121
)
2222
)(identity).asExprOf[Int]

tests/pos-macros/i8866b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object Macro {
1111

1212
ValDef.let(
1313
Select.unique(
14-
'{ Other }.unseal,
14+
'{ Other }.asReflectTree,
1515
"apply"
1616
)
1717
)(identity).asExprOf[Int]

tests/pos-macros/i9251/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Async {
2121
def checkPrintTypeImpl[F[_]:Type,T:Type](f: Expr[T])(using qctx: QuoteContext): Expr[Unit] =
2222
import qctx.reflect._
2323

24-
val fu = f.unseal
24+
val fu = f.asReflectTree
2525
fu match
2626
case Inlined(_,_,Block(_,Apply(TypeApply(Select(q,n),tparams),List(param)))) =>
2727
param.tpe match

tests/pos-macros/i9518/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ inline def shift : Unit = ${ shiftTerm }
77

88
def shiftTerm(using QuoteContext): Expr[Unit] = {
99
import qctx.reflect._
10-
val nTree = '{ ??? : CB[Int] }.unseal
10+
val nTree = '{ ??? : CB[Int] }.asReflectTree
1111
val tp1 = TypeRepr.of[CB[Int]]
1212
val tp2 = TypeRepr.of[([X] =>> CB[X])[Int]]
1313
val ta = Type.of[[X] =>> CB[X]]

tests/pos-macros/i9687/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ object X {
2424

2525
def transformImpl[A:Type](x:Expr[A])(using qctx: QuoteContext):Expr[A] = {
2626
import qctx.reflect._
27-
val slowPath = '{ SlowPath }.unseal
28-
val fastPath = '{ FastPath }.unseal
27+
val slowPath = '{ SlowPath }.asReflectTree
28+
val fastPath = '{ FastPath }.asReflectTree
2929
val transformer = new TreeMap() {
3030
override def transformTerm(term:Term)(using ctx:Context):Term = {
3131
term match
@@ -37,7 +37,7 @@ object X {
3737
case _ => super.transformTerm(term)
3838
}
3939
}
40-
val r = transformer.transformTerm(x.unseal).asExprOf[A]
40+
val r = transformer.transformTerm(x.asReflectTree).asExprOf[A]
4141
s"result: ${r.show}"
4242
r
4343
}

tests/pos-macros/i9894/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object X:
3636
case Block(stats, last) => Block(stats, transform(last))
3737
case Inlined(x,List(),body) => transform(body)
3838
case l@Literal(x) =>
39-
'{ CBM.pure(${term.asExpr}) }.unseal
39+
'{ CBM.pure(${term.asExpr}) }.asReflectTree
4040
case other =>
4141
throw RuntimeException(s"Not supported $other")
4242

@@ -64,4 +64,4 @@ object X:
6464
}
6565
changes.transformTerm(body)
6666

67-
transform(f.unseal).asExprOf[CB[T]]
67+
transform(f.asReflectTree).asExprOf[CB[T]]

tests/pos-macros/treemap-unapply/Macro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import scala.quoted._
33
inline def mcr(x: => Unit): Unit = ${mcrImpl('x)}
44
def mcrImpl(x: Expr[Unit])(using QuoteContext) : Expr[Unit] =
55
import qctx.reflect._
6-
val tr: Term = x.unseal
6+
val tr: Term = x.asReflectTree
77
object m extends TreeMap
88
m.transformTerm(tr).asExprOf[Unit]

tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala

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

88
def inspectBodyImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[String] = {
99
import qctx.reflect._
10-
x.unseal match {
10+
x.asReflectTree match {
1111
case Inlined(None, Nil, arg) => Expr(arg.symbol.tree.showExtractors)
1212
case arg => Expr(arg.symbol.tree.showExtractors) // TODO should all by name parameters be in an inline node?
1313
}

tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala

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

88
def inspectBodyImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[String] = {
99
import qctx.reflect._
10-
x.unseal match {
10+
x.asReflectTree match {
1111
case Inlined(None, Nil, arg) => Expr(arg.symbol.tree.showExtractors)
1212
case arg => Expr(arg.symbol.tree.showExtractors) // TODO should all by name parameters be in an inline node?
1313
}

0 commit comments

Comments
 (0)