diff --git a/community-build/community-projects/dotty-cps-async b/community-build/community-projects/dotty-cps-async index b10a1c62e2be..bb1eec6166dc 160000 --- a/community-build/community-projects/dotty-cps-async +++ b/community-build/community-projects/dotty-cps-async @@ -1 +1 @@ -Subproject commit b10a1c62e2bee465975aa47a1358b4fd33cdebc7 +Subproject commit bb1eec6166dcef7e2fbe74a6baaee8041764471c diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 575d8d0b9abd..8572cb694988 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 575d8d0b9abd6566b55c216efc3070b76e0f3ddd +Subproject commit 8572cb6949889c08e5161dfed53e7dcce3a78793 diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index 93a368734acf..ba4edb34f9ac 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit 93a368734acf082d653592770c5b064270476ee7 +Subproject commit ba4edb34f9ac4083d5eb4f025a3fbc98a1ebfc3d diff --git a/community-build/community-projects/utest b/community-build/community-projects/utest index c1d9ec9c81bb..78281c05e6e0 160000 --- a/community-build/community-projects/utest +++ b/community-build/community-projects/utest @@ -1 +1 @@ -Subproject commit c1d9ec9c81bb33ea574150dc3813e38ab30f9955 +Subproject commit 78281c05e6e06f7bc52c639da161bfac65a53980 diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index fd42b001992d..52e0f24b01cf 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit fd42b001992d58648d019f35d99cbe9cf2b0b224 +Subproject commit 52e0f24b01cffd114375db4c741e1ff3ea71fbc8 diff --git a/compiler/src/dotty/tools/dotc/quoted/Matcher.scala b/compiler/src/dotty/tools/dotc/quoted/Matcher.scala index d8fcb61398d9..371ee20a723f 100644 --- a/compiler/src/dotty/tools/dotc/quoted/Matcher.scala +++ b/compiler/src/dotty/tools/dotc/quoted/Matcher.scala @@ -183,14 +183,14 @@ object Matcher { if patternHole.symbol == patternHoleSymbol && s.tpe <:< tpt.tpe && tpt2.tpe.derivesFrom(defn.RepeatedParamClass) => - matched(scrutinee.seal) + matched(scrutinee.asExpr) /* Term hole */ // Match a scala.internal.Quoted.patternHole and return the scrutinee tree case (ClosedPatternTerm(scrutinee), TypeApply(patternHole, tpt :: Nil)) if patternHole.symbol == patternHoleSymbol && scrutinee.tpe <:< tpt.tpe => - matched(scrutinee.seal) + matched(scrutinee.asExpr) /* Higher order term hole */ // Matches an open term and wraps it into a lambda that provides the free variables @@ -213,7 +213,7 @@ object Matcher { val argTypes = args.map(x => x.tpe.widenTermRefExpr) val resType = pattern.tpe val res = Lambda(MethodType(names)(_ => argTypes, _ => resType), bodyFn) - matched(res.seal) + matched(res.asExpr) // // Match two equivalent trees diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index cdce5fb1145d..6ae8b5527fe4 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -49,7 +49,7 @@ def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = { Reporting.error("Parameter must be natural number") '{0} } else { - xTree.seal.cast[Int] + xTree.asExprOf[Int] } case _ => Reporting.error("Parameter must be a known constant") @@ -61,10 +61,9 @@ def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = { To easily know which extractors are needed, the `showExtractors` method on a `qctx.reflect.Term` returns the string representation of the extractors. -The method `qctx.reflect.Term.seal` provides a way to go back to a -`quoted.Expr[Any]`. Note that the type is `Expr[Any]`. Consequently, the type -must be set explicitly with a checked `cast` call. If the type does not conform -to it an exception will be thrown at runtime. +The methods `qctx.reflect.Term.{asExpr, asExprOf}` provide a way to go back to a `quoted.Expr`. +Note that `asExpr` returns a `Expr[Any]`. +On the other hand `asExprOf[T]` returns a `Expr[T]`, if the type does not conform to it an exception will be thrown at runtime. ### Positions diff --git a/library/src-bootstrapped/scala/quoted/Expr.scala b/library/src-bootstrapped/scala/quoted/Expr.scala index cf50547421aa..33e536d1fbda 100644 --- a/library/src-bootstrapped/scala/quoted/Expr.scala +++ b/library/src-bootstrapped/scala/quoted/Expr.scala @@ -15,7 +15,7 @@ object Expr { */ def betaReduce[T](expr: Expr[T])(using qctx: QuoteContext): Expr[T] = qctx.reflect.Term.betaReduce(expr.unseal) match - case Some(expr1) => expr1.seal.asInstanceOf[Expr[T]] + case Some(expr1) => expr1.asExpr.asInstanceOf[Expr[T]] case _ => expr /** Returns an expression containing a block with the given statements and ending with the expresion @@ -24,7 +24,7 @@ object Expr { */ def block[T](statements: List[Expr[Any]], expr: Expr[T])(using qctx: QuoteContext): Expr[T] = { import qctx.reflect._ - Block(statements.map(_.unseal), expr.unseal).seal.asInstanceOf[Expr[T]] + Block(statements.map(_.unseal), expr.unseal).asExpr.asInstanceOf[Expr[T]] } /** Lift a value into an expression containing the construction of that value */ @@ -211,7 +211,7 @@ object Expr { def summon[T](using tpe: Type[T])(using qctx: QuoteContext): Option[Expr[T]] = { import qctx.reflect._ Implicits.search(TypeRepr.of[T]) match { - case iss: ImplicitSearchSuccess => Some(iss.tree.seal.asInstanceOf[Expr[T]]) + case iss: ImplicitSearchSuccess => Some(iss.tree.asExpr.asInstanceOf[Expr[T]]) case isf: ImplicitSearchFailure => None } } diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index 2641da147a94..2247356471f7 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -25,70 +25,70 @@ object Liftable { given BooleanLiftable[T <: Boolean] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Boolean(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Boolean(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Byte */ given ByteLiftable[T <: Byte] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Byte(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Byte(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Short */ given ShortLiftable[T <: Short] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Short(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Short(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Int */ given IntLiftable[T <: Int] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Int(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Int(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Long */ given LongLiftable[T <: Long] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Long(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Long(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Float */ given FloatLiftable[T <: Float] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Float(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Float(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Double */ given DoubleLiftable[T <: Double] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Double(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Double(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Char */ given CharLiftable[T <: Char] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.Char(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Char(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for String */ given StringLiftable[T <: String] as Liftable[T] { def toExpr(x: T) = import qctx.reflect._ - Literal(Constant.String(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.String(x)).asExpr.asInstanceOf[Expr[T]] } /** Default liftable for Class[T] */ given ClassLiftable[T] as Liftable[Class[T]] = new Liftable[Class[T]] { def toExpr(x: Class[T]) = { import qctx.reflect._ - Ref(defn.Predef_classOf).appliedToType(TypeRepr.typeConstructorOf(x)).seal.asInstanceOf[Expr[Class[T]]] + Ref(defn.Predef_classOf).appliedToType(TypeRepr.typeConstructorOf(x)).asExpr.asInstanceOf[Expr[Class[T]]] } } diff --git a/library/src-bootstrapped/scala/quoted/Varargs.scala b/library/src-bootstrapped/scala/quoted/Varargs.scala index 12be6b530aff..5811dd338a25 100644 --- a/library/src-bootstrapped/scala/quoted/Varargs.scala +++ b/library/src-bootstrapped/scala/quoted/Varargs.scala @@ -17,7 +17,7 @@ object Varargs { */ def apply[T](xs: Seq[Expr[T]])(using tp: Type[T], qctx: QuoteContext): Expr[Seq[T]] = { import qctx.reflect._ - Repeated(xs.map[Term](_.unseal).toList, TypeTree.of[T]).seal.asInstanceOf[Expr[Seq[T]]] + Repeated(xs.map[Term](_.unseal).toList, TypeTree.of[T]).asExpr.asInstanceOf[Expr[Seq[T]]] } /** Matches a literal sequence of expressions and return a sequence of expressions. @@ -35,7 +35,7 @@ object Varargs { def unapply[T](expr: Expr[Seq[T]])(using qctx: QuoteContext): Option[Seq[Expr[T]]] = { import qctx.reflect._ def rec(tree: Term): Option[Seq[Expr[T]]] = tree match { - case Typed(Repeated(elems, _), _) => Some(elems.map(x => x.seal.asInstanceOf[Expr[T]])) + case Typed(Repeated(elems, _), _) => Some(elems.map(x => x.asExpr.asInstanceOf[Expr[T]])) case Block(Nil, e) => rec(e) case Inlined(_, Nil, e) => rec(e) case _ => None diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index b2241d3d214b..d18181f1bd38 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -391,12 +391,6 @@ trait Reflection { reflection => trait TermMethods { extension (self: Term): - /** Convert `Term` to an `quoted.Expr[Any]` if the term is a valid expression or throws */ - def seal: scala.quoted.Expr[Any] - - /** Convert `Term` to an `quoted.Expr[Any]` if the term is a valid expression */ - def sealOpt: Option[scala.quoted.Expr[Any]] - /** TypeRepr of this term */ def tpe: TypeRepr diff --git a/tests/pos-macros/i6535/Macro_1.scala b/tests/pos-macros/i6535/Macro_1.scala index 54f52e8a3581..145cedc6184a 100644 --- a/tests/pos-macros/i6535/Macro_1.scala +++ b/tests/pos-macros/i6535/Macro_1.scala @@ -15,8 +15,8 @@ object scalatest { let(rhs) { right => val app = Select.overloaded(left, op, Nil, right :: Nil) let(app) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal diff --git a/tests/pos-macros/i7011/Macros_1.scala b/tests/pos-macros/i7011/Macros_1.scala index f269b0cfafe2..1557a75c7283 100644 --- a/tests/pos-macros/i7011/Macros_1.scala +++ b/tests/pos-macros/i7011/Macros_1.scala @@ -8,7 +8,7 @@ def mcrImpl[T](body: Expr[Any])(using QuoteContext) : Expr[Any] = { val bTree = body.unseal val under = bTree.underlyingArgument - val res = '{Box(${under.asInstanceOf[Term].seal})} + val res = '{Box(${under.asInstanceOf[Term].asExpr})} res } diff --git a/tests/pos-macros/i7030/Macros_1.scala b/tests/pos-macros/i7030/Macros_1.scala index 9c52700ad274..ec6c41753811 100644 --- a/tests/pos-macros/i7030/Macros_1.scala +++ b/tests/pos-macros/i7030/Macros_1.scala @@ -7,5 +7,5 @@ def innerImpl(exprs: Expr[Any])(using QuoteContext): Expr[Any] = inline def outer(expr: => Any): Any = ${outerImpl('expr)} def outerImpl(body: Expr[Any])(using QuoteContext): Expr[Any] = { import qctx.reflect._ - body.unseal.underlyingArgument.seal + body.unseal.underlyingArgument.asExpr } diff --git a/tests/pos-macros/i8325/Macro_1.scala b/tests/pos-macros/i8325/Macro_1.scala index 7f242bc344e3..97b652f245fd 100644 --- a/tests/pos-macros/i8325/Macro_1.scala +++ b/tests/pos-macros/i8325/Macro_1.scala @@ -14,8 +14,8 @@ object A: def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = { import qctx.reflect._ expr.unseal match { - case Inlined(x,y,z) => transformImplExpr(z.seal.asInstanceOf[Expr[A]]) - case Apply(fun,args) => '{ A.pure(${Apply(fun,args).seal.asInstanceOf[Expr[A]]}) } + case Inlined(x,y,z) => transformImplExpr(z.asExpr.asInstanceOf[Expr[A]]) + case Apply(fun,args) => '{ A.pure(${Apply(fun,args).asExpr.asInstanceOf[Expr[A]]}) } case other => expr } } diff --git a/tests/pos-macros/i8325b/Macro_1.scala b/tests/pos-macros/i8325b/Macro_1.scala index 276fb4dcd057..70dc5ab63772 100644 --- a/tests/pos-macros/i8325b/Macro_1.scala +++ b/tests/pos-macros/i8325b/Macro_1.scala @@ -14,9 +14,9 @@ object A: def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = { import qctx.reflect._ expr.unseal match { - case Inlined(x,y,z) => transformImplExpr(z.seal.asInstanceOf[Expr[A]]) + case Inlined(x,y,z) => transformImplExpr(z.asExpr.asInstanceOf[Expr[A]]) case r@Apply(fun,args) => '{ - A.pure(${r.seal.asInstanceOf[Expr[A]]}) } + A.pure(${r.asExpr.asInstanceOf[Expr[A]]}) } case other => expr } } diff --git a/tests/pos-macros/i9894/Macro_1.scala b/tests/pos-macros/i9894/Macro_1.scala index 287f87846911..8f274c3a75b7 100644 --- a/tests/pos-macros/i9894/Macro_1.scala +++ b/tests/pos-macros/i9894/Macro_1.scala @@ -36,7 +36,7 @@ object X: case Block(stats, last) => Block(stats, transform(last)) case Inlined(x,List(),body) => transform(body) case l@Literal(x) => - '{ CBM.pure(${term.seal}) }.unseal + '{ CBM.pure(${term.asExpr}) }.unseal case other => throw RuntimeException(s"Not supported $other") diff --git a/tests/run-macros/f-interpolation-1/FQuote_1.scala b/tests/run-macros/f-interpolation-1/FQuote_1.scala index 1c2f800cdee8..5f63fab7255a 100644 --- a/tests/run-macros/f-interpolation-1/FQuote_1.scala +++ b/tests/run-macros/f-interpolation-1/FQuote_1.scala @@ -13,7 +13,7 @@ object FQuote { def liftListOfAny(lst: List[Term]): Expr[List[Any]] = lst match { case x :: xs => - val head = x.seal + val head = x.asExpr val tail = liftListOfAny(xs) '{ $head :: $tail } case Nil => '{Nil} diff --git a/tests/run-macros/i5533b/Macro_1.scala b/tests/run-macros/i5533b/Macro_1.scala index 952fc1653b88..a6cc9d13941f 100644 --- a/tests/run-macros/i5533b/Macro_1.scala +++ b/tests/run-macros/i5533b/Macro_1.scala @@ -13,8 +13,8 @@ object scalatest { tree.underlyingArgument match { case Apply(Select(lhs, op), rhs :: Nil) => - val left = lhs.seal - val right = rhs.seal + val left = lhs.asExpr + val right = rhs.asExpr op match { case "==" => '{ diff --git a/tests/run-macros/i5536/Macro_1.scala b/tests/run-macros/i5536/Macro_1.scala index 5386d4095143..09cf6b06106f 100644 --- a/tests/run-macros/i5536/Macro_1.scala +++ b/tests/run-macros/i5536/Macro_1.scala @@ -10,8 +10,8 @@ object scalatest { tree.underlyingArgument match { case Apply(Select(lhs, op), rhs :: Nil) => - val left = lhs.seal - val right = rhs.seal + val left = lhs.asExpr + val right = rhs.asExpr op match { case "===" => '{ diff --git a/tests/run-macros/i6171/Macro_1.scala b/tests/run-macros/i6171/Macro_1.scala index f14f70474d3a..aca90da66d1b 100644 --- a/tests/run-macros/i6171/Macro_1.scala +++ b/tests/run-macros/i6171/Macro_1.scala @@ -18,8 +18,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Select.overloaded(left, op, Nil, right :: Nil) ValDef.let(app) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal @@ -32,8 +32,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Select.overloaded(Apply(qual, left :: Nil), op, Nil, right :: Nil) ValDef.let(Apply(app, implicits)) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal diff --git a/tests/run-macros/i6988/FirstArg_1.scala b/tests/run-macros/i6988/FirstArg_1.scala index 54facdb43d79..deb231c7d47b 100644 --- a/tests/run-macros/i6988/FirstArg_1.scala +++ b/tests/run-macros/i6988/FirstArg_1.scala @@ -23,10 +23,10 @@ object Macros { else enclosingParamList(owner.owner) def literal(value: String): Expr[String] = - Literal(Constant.String(value)).seal.asInstanceOf[Expr[String]] + Literal(Constant.String(value)).asExpr.asInstanceOf[Expr[String]] val paramss = enclosingParamList(Symbol.currentOwner) val firstArg = paramss.flatten.head val ref = Select.unique(This(enclosingClass()), firstArg.name) - '{ FirstArg(${ref.seal}, ${Expr(firstArg.name)}) } + '{ FirstArg(${ref.asExpr}, ${Expr(firstArg.name)}) } } } diff --git a/tests/run-macros/i7898/Macro_1.scala b/tests/run-macros/i7898/Macro_1.scala index 422628268018..2201491d8b52 100644 --- a/tests/run-macros/i7898/Macro_1.scala +++ b/tests/run-macros/i7898/Macro_1.scala @@ -8,7 +8,7 @@ object Main { val showed = bodyTerm.show '{ println(${Expr(showed)}) - ${bodyTerm.seal} + ${bodyTerm.asExpr} } } @@ -17,5 +17,5 @@ object Main { } def underlyingArgument[T](expr: Expr[T])(using qctx: QuoteContext): Expr[T] = - expr.unseal.underlyingArgument.seal.asInstanceOf[Expr[T]] + expr.unseal.underlyingArgument.asExpr.asInstanceOf[Expr[T]] } diff --git a/tests/run-macros/i8007/Macro_2.scala b/tests/run-macros/i8007/Macro_2.scala index 0c75fb165aab..c0ba33aa47a1 100644 --- a/tests/run-macros/i8007/Macro_2.scala +++ b/tests/run-macros/i8007/Macro_2.scala @@ -30,7 +30,7 @@ object Macro2 { val body: Expr[T] => Expr[String] = elem => fields.reverse.foldLeft(Expr("")){ (acc, field) => - val res = Select.unique(elem.unseal, field).seal + val res = Select.unique(elem.unseal, field).asExpr '{ $res.toString + " " + $acc } } diff --git a/tests/run-macros/i9812b/Macro_1.scala b/tests/run-macros/i9812b/Macro_1.scala index 715bf037b895..1f44e602257b 100644 --- a/tests/run-macros/i9812b/Macro_1.scala +++ b/tests/run-macros/i9812b/Macro_1.scala @@ -29,7 +29,7 @@ case object NIL extends Lst[Nothing] given IntLiftable[T <: Int] as Liftable[T]: def toExpr(x: T): QuoteContext ?=> Expr[T] = (using qctx) => { import qctx.reflect._ - Literal(Constant.Int(x)).seal.asInstanceOf[Expr[T]] + Literal(Constant.Int(x)).asExpr.asInstanceOf[Expr[T]] } given LiftLst[T: Type: Liftable](using ev1: => Liftable[CONS[T]], ev2: => Liftable[NIL.type]) as Liftable[Lst[T]]: diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index 0a90645da43c..4824ab35fef0 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -65,12 +65,12 @@ object Macros { object UnsafeExpr { def open[T1, R, X](f: Expr[T1 => R])(content: (Expr[R], [t] => Expr[t] => Expr[T1] => Expr[t]) => X)(using qctx: QuoteContext): X = { val (params, bodyExpr) = paramsAndBody[R](f) - content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).seal.asInstanceOf[Expr[t]]) + content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).asExpr.asInstanceOf[Expr[t]]) } private def paramsAndBody[R](using qctx: QuoteContext)(f: Expr[Any]): (List[qctx.reflect.ValDef], Expr[R]) = { import qctx.reflect._ val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.unseal.etaExpand - (params, body.seal.asInstanceOf[Expr[R]]) + (params, body.asExpr.asInstanceOf[Expr[R]]) } private def bodyFn[t](using qctx: QuoteContext)(e: qctx.reflect.Term, params: List[qctx.reflect.ValDef], args: List[qctx.reflect.Term]): qctx.reflect.Term = { diff --git a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala index d5a8ae242423..52fece7310c7 100644 --- a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala @@ -77,12 +77,12 @@ object Macros { object UnsafeExpr { def open[T1, R, X](f: Expr[T1 => R])(content: (Expr[R], [t] => Expr[t] => Expr[T1] => Expr[t]) => X)(using qctx: QuoteContext): X = { val (params, bodyExpr) = paramsAndBody[R](f) - content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).seal.asInstanceOf[Expr[t]]) + content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).asExpr.asInstanceOf[Expr[t]]) } private def paramsAndBody[R](using qctx: QuoteContext)(f: Expr[Any]): (List[qctx.reflect.ValDef], Expr[R]) = { import qctx.reflect._ val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.unseal.etaExpand - (params, body.seal.asInstanceOf[Expr[R]]) + (params, body.asExpr.asInstanceOf[Expr[R]]) } private def bodyFn[t](using qctx: QuoteContext)(e: qctx.reflect.Term, params: List[qctx.reflect.ValDef], args: List[qctx.reflect.Term]): qctx.reflect.Term = { diff --git a/tests/run-macros/quote-matching-open/Macro_1.scala b/tests/run-macros/quote-matching-open/Macro_1.scala index 5489054b3097..c1c1ca1a957f 100644 --- a/tests/run-macros/quote-matching-open/Macro_1.scala +++ b/tests/run-macros/quote-matching-open/Macro_1.scala @@ -18,21 +18,21 @@ object Macro { object UnsafeExpr { def open[T1, R, X](f: Expr[T1 => R])(content: (Expr[R], [t] => Expr[t] => Expr[T1] => Expr[t]) => X)(using qctx: QuoteContext): X = { val (params, bodyExpr) = paramsAndBody[R](f) - content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).seal.asInstanceOf[Expr[t]]) + content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).asExpr.asInstanceOf[Expr[t]]) } def open[T1, T2, R, X](f: Expr[(T1, T2) => R])(content: (Expr[R], [t] => Expr[t] => (Expr[T1], Expr[T2]) => Expr[t]) => X)(using qctx: QuoteContext)(using DummyImplicit): X = { val (params, bodyExpr) = paramsAndBody[R](f) - content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal)).seal.asInstanceOf[Expr[t]]) + content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal)).asExpr.asInstanceOf[Expr[t]]) } def open[T1, T2, T3, R, X](f: Expr[(T1, T2, T3) => R])(content: (Expr[R], [t] => Expr[t] => (Expr[T1], Expr[T2], Expr[T3]) => Expr[t]) => X)(using qctx: QuoteContext)(using DummyImplicit, DummyImplicit): X = { val (params, bodyExpr) = paramsAndBody[R](f) - content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2], v3: Expr[T3]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal, v3.unseal)).seal.asInstanceOf[Expr[t]]) + content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2], v3: Expr[T3]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal, v3.unseal)).asExpr.asInstanceOf[Expr[t]]) } private def paramsAndBody[R](using qctx: QuoteContext)(f: Expr[Any]): (List[qctx.reflect.ValDef], Expr[R]) = { import qctx.reflect._ val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.unseal.etaExpand - (params, body.seal.asInstanceOf[Expr[R]]) + (params, body.asExpr.asInstanceOf[Expr[R]]) } private def bodyFn[t](using qctx: QuoteContext)(e: qctx.reflect.Term, params: List[qctx.reflect.ValDef], args: List[qctx.reflect.Term]): qctx.reflect.Term = { diff --git a/tests/run-macros/quoted-matching-docs/Macro_1.scala b/tests/run-macros/quoted-matching-docs/Macro_1.scala index 3c714c03b6b2..8b7f0fa69ed1 100644 --- a/tests/run-macros/quoted-matching-docs/Macro_1.scala +++ b/tests/run-macros/quoted-matching-docs/Macro_1.scala @@ -29,5 +29,5 @@ private def sumExpr(argsExpr: Expr[Seq[Int]])(using qctx: QuoteContext) : Expr[I object UnsafeExpr { def underlyingArgument[T](expr: Expr[T])(using qctx: QuoteContext): Expr[T] = - expr.unseal.underlyingArgument.seal.asInstanceOf[Expr[T]] + expr.unseal.underlyingArgument.asExpr.asInstanceOf[Expr[T]] } \ No newline at end of file diff --git a/tests/run-macros/reflect-dsl/assert_1.scala b/tests/run-macros/reflect-dsl/assert_1.scala index 2034ecb11948..7fa936d70c74 100644 --- a/tests/run-macros/reflect-dsl/assert_1.scala +++ b/tests/run-macros/reflect-dsl/assert_1.scala @@ -18,8 +18,8 @@ object scalatest { ValDef.let(rhs) { right => val app = left.select(sel.symbol).appliedTo(right) ValDef.let(app) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal @@ -32,8 +32,8 @@ object scalatest { ValDef.let(rhs) { right => val app = qual.appliedTo(left).select(sel.symbol).appliedTo(right) ValDef.let(Apply(app, implicits)) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal diff --git a/tests/run-macros/reflect-select-constructor/assert_1.scala b/tests/run-macros/reflect-select-constructor/assert_1.scala index 0ae35175753a..09c3e738be88 100644 --- a/tests/run-macros/reflect-select-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-constructor/assert_1.scala @@ -18,8 +18,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Select.overloaded(left, op, Nil, right :: Nil) ValDef.let(app) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal @@ -32,8 +32,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Select.overloaded(Apply(qual, left :: Nil), op, Nil, right :: Nil) ValDef.let(Apply(app, implicits)) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal diff --git a/tests/run-macros/reflect-select-copy-2/assert_1.scala b/tests/run-macros/reflect-select-copy-2/assert_1.scala index 58e3b4fb3ad4..3a95072d4b84 100644 --- a/tests/run-macros/reflect-select-copy-2/assert_1.scala +++ b/tests/run-macros/reflect-select-copy-2/assert_1.scala @@ -17,8 +17,8 @@ object scalatest { ValDef.let(lhs) { left => ValDef.let(rhs) { right => ValDef.let(Apply(Select.copy(sel)(left, op), right :: Nil)) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert(${b}) } code.unseal @@ -30,8 +30,8 @@ object scalatest { ValDef.let(lhs) { left => ValDef.let(rhs) { right => ValDef.let(Apply(Apply(Select.copy(sel)(Apply(qual, left :: Nil), op), right :: Nil), implicits)) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert(${b}) } code.unseal diff --git a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala index d6d99381d299..6eb43e90a35b 100644 --- a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala @@ -18,8 +18,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Apply(Select(left, sel.symbol), right :: Nil) ValDef.let(app) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal @@ -32,8 +32,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Apply(Select(Apply(qual, left :: Nil), sel.symbol), right :: Nil) ValDef.let(Apply(app, implicits)) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal diff --git a/tests/run-macros/reflect-select-value-class/assert_1.scala b/tests/run-macros/reflect-select-value-class/assert_1.scala index be28a2748878..7db21b353526 100644 --- a/tests/run-macros/reflect-select-value-class/assert_1.scala +++ b/tests/run-macros/reflect-select-value-class/assert_1.scala @@ -18,8 +18,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Select.overloaded(left, op, Nil, right :: Nil) ValDef.let(app) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal @@ -32,8 +32,8 @@ object scalatest { ValDef.let(rhs) { right => val app = Select.overloaded(Apply(qual, left :: Nil), op, Nil, right :: Nil) ValDef.let(Apply(app, implicits)) { result => - val l = left.seal - val r = right.seal + val l = left.asExpr + val r = right.asExpr val b = result.asExprOf[Boolean] val code = '{ scala.Predef.assert($b) } code.unseal diff --git a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala index 8d296e1d58af..bd37411fe8fb 100644 --- a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala +++ b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala @@ -20,10 +20,10 @@ object Macros { DefDef(sym1, { case List() => { case List(List(a, b)) => - Some('{ ${ a.seal.asInstanceOf[Expr[Int]] } - ${ b.seal.asInstanceOf[Expr[Int]] } }.unseal) + Some('{ ${ a.asExpr.asInstanceOf[Expr[Int]] } - ${ b.asExpr.asInstanceOf[Expr[Int]] } }.unseal) } }), - '{ assert(${ Apply(Ref(sym1), List(Literal(Constant.Int(2)), Literal(Constant.Int(3)))).seal.asInstanceOf[Expr[Int]] } == -1) }.unseal) + '{ assert(${ Apply(Ref(sym1), List(Literal(Constant.Int(2)), Literal(Constant.Int(3)))).asExpr.asInstanceOf[Expr[Int]] } == -1) }.unseal) // test for no argument list (no Apply node) val sym2 : Symbol = Symbol.newMethod( @@ -39,7 +39,7 @@ object Macros { Some(Literal(Constant.Int(2))) } }), - '{ assert(${ Ref(sym2).seal.asInstanceOf[Expr[Int]] } == 2) }.unseal) + '{ assert(${ Ref(sym2).asExpr.asInstanceOf[Expr[Int]] } == 2) }.unseal) // test for multiple argument lists val sym3 : Symbol = Symbol.newMethod( @@ -59,7 +59,7 @@ object Macros { Some(a) } }), - '{ assert(${ Apply(Apply(Ref(sym3), List(Literal(Constant.Int(3)))), List(Literal(Constant.Int(3)))).seal.asInstanceOf[Expr[Int]] } == 3) }.unseal) + '{ assert(${ Apply(Apply(Ref(sym3), List(Literal(Constant.Int(3)))), List(Literal(Constant.Int(3)))).asExpr.asInstanceOf[Expr[Int]] } == 3) }.unseal) // test for recursive references val sym4 : Symbol = Symbol.newMethod( @@ -75,13 +75,13 @@ object Macros { case List() => { case List(List(x)) => Some('{ - if ${ x.seal.asInstanceOf[Expr[Int]] } == 0 + if ${ x.asExpr.asInstanceOf[Expr[Int]] } == 0 then 0 - else ${ Apply(Ref(sym4), List('{ ${ x.seal.asInstanceOf[Expr[Int]] } - 1 }.unseal)).seal.asInstanceOf[Expr[Int]] } + else ${ Apply(Ref(sym4), List('{ ${ x.asExpr.asInstanceOf[Expr[Int]] } - 1 }.unseal)).asExpr.asInstanceOf[Expr[Int]] } }.unseal) } }), - '{ assert(${ Apply(Ref(sym4), List(Literal(Constant.Int(4)))).seal.asInstanceOf[Expr[Int]] } == 0) }.unseal) + '{ assert(${ Apply(Ref(sym4), List(Literal(Constant.Int(4)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.unseal) // test for nested functions (one symbol is the other's parent, and we use a Closure) val sym5 : Symbol = Symbol.newMethod( @@ -108,14 +108,14 @@ object Macros { DefDef(sym51, { case List() => { case List(List(xx)) => - Some('{ ${ x.seal.asInstanceOf[Expr[Int]] } - ${ xx.seal.asInstanceOf[Expr[Int]] } }.unseal) + Some('{ ${ x.asExpr.asInstanceOf[Expr[Int]] } - ${ xx.asExpr.asInstanceOf[Expr[Int]] } }.unseal) } })), Closure(Ref(sym51), None)) } } }), - '{ assert(${ Apply(Ref(sym5), List(Literal(Constant.Int(5)))).seal.asInstanceOf[Expr[Int=>Int]] }(4) == 1) }.unseal) + '{ assert(${ Apply(Ref(sym5), List(Literal(Constant.Int(5)))).asExpr.asInstanceOf[Expr[Int=>Int]] }(4) == 1) }.unseal) // test mutually recursive definitions val sym6_1 : Symbol = Symbol.newMethod( @@ -140,10 +140,10 @@ object Macros { case List(List(x)) => Some { '{ - println(s"sym6_1: ${ ${ x.seal.asInstanceOf[Expr[Int]] } }") - if ${ x.seal.asInstanceOf[Expr[Int]] } == 0 + println(s"sym6_1: ${ ${ x.asExpr.asInstanceOf[Expr[Int]] } }") + if ${ x.asExpr.asInstanceOf[Expr[Int]] } == 0 then 0 - else ${ Apply(Ref(sym6_2), List('{ ${ x.seal.asInstanceOf[Expr[Int]] } - 1 }.unseal)).seal.asInstanceOf[Expr[Int]] } + else ${ Apply(Ref(sym6_2), List('{ ${ x.asExpr.asInstanceOf[Expr[Int]] } - 1 }.unseal)).asExpr.asInstanceOf[Expr[Int]] } }.unseal } } @@ -153,16 +153,16 @@ object Macros { case List(List(x)) => Some { '{ - println(s"sym6_2: ${ ${ x.seal.asInstanceOf[Expr[Int]] } }") - if ${ x.seal.asInstanceOf[Expr[Int]] } == 0 + println(s"sym6_2: ${ ${ x.asExpr.asInstanceOf[Expr[Int]] } }") + if ${ x.asExpr.asInstanceOf[Expr[Int]] } == 0 then 0 - else ${ Apply(Ref(sym6_1), List('{ ${ x.seal.asInstanceOf[Expr[Int]] } - 1 }.unseal)).seal.asInstanceOf[Expr[Int]] } + else ${ Apply(Ref(sym6_1), List('{ ${ x.asExpr.asInstanceOf[Expr[Int]] } - 1 }.unseal)).asExpr.asInstanceOf[Expr[Int]] } }.unseal } } }), - '{ assert(${ Apply(Ref(sym6_2), List(Literal(Constant.Int(6)))).seal.asInstanceOf[Expr[Int]] } == 0) }.unseal) + '{ assert(${ Apply(Ref(sym6_2), List(Literal(Constant.Int(6)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.unseal) // test polymorphic methods by synthesizing an identity method val sym7 : Symbol = Symbol.newMethod( @@ -182,7 +182,7 @@ object Macros { Some(Typed(x, Inferred(t))) } }), - '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(TypeRepr.of[Int]))), List(Literal(Constant.Int(7)))).seal.asInstanceOf[Expr[Int]] } == 7) }.unseal) + '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(TypeRepr.of[Int]))), List(Literal(Constant.Int(7)))).asExpr.asInstanceOf[Expr[Int]] } == 7) }.unseal) Block( sym1Statements ++ @@ -193,7 +193,7 @@ object Macros { sym6Statements ++ sym7Statements ++ List('{ println("Ok") }.unseal), - Literal(Constant.Unit())).seal.asInstanceOf[Expr[Unit]] + Literal(Constant.Unit())).asExpr.asInstanceOf[Expr[Unit]] } } diff --git a/tests/run-macros/tasty-interpolation-1/Macro.scala b/tests/run-macros/tasty-interpolation-1/Macro.scala index 5c7d02bd64f4..c2ed8f270ce9 100644 --- a/tests/run-macros/tasty-interpolation-1/Macro.scala +++ b/tests/run-macros/tasty-interpolation-1/Macro.scala @@ -60,19 +60,19 @@ abstract class MacroStringInterpolator[T] { case Select(Typed(Apply(_, List(Apply(_, List(Typed(Repeated(strCtxArgTrees, _), Inferred()))))), _), _) => val strCtxArgs = strCtxArgTrees.map { case Literal(Constant.String(str)) => str - case tree => throw new NotStaticlyKnownError("Expected statically known StringContext", tree.seal) + case tree => throw new NotStaticlyKnownError("Expected statically known StringContext", tree.asExpr) } StringContext(strCtxArgs: _*) case tree => - throw new NotStaticlyKnownError("Expected statically known StringContext", tree.seal) + throw new NotStaticlyKnownError("Expected statically known StringContext", tree.asExpr) } } protected def getArgsList(argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : List[Expr[Any]] = { import qctx.reflect._ argsExpr.unseal.underlyingArgument match { - case Typed(Repeated(args, _), _) => args.map(_.seal) - case tree => throw new NotStaticlyKnownError("Expected statically known argument list", tree.seal) + case Typed(Repeated(args, _), _) => args.map(_.asExpr) + case tree => throw new NotStaticlyKnownError("Expected statically known argument list", tree.asExpr) } } diff --git a/tests/run-macros/tasty-macro-assert/quoted_1.scala b/tests/run-macros/tasty-macro-assert/quoted_1.scala index 25e11e38170d..1342c8dccec4 100644 --- a/tests/run-macros/tasty-macro-assert/quoted_1.scala +++ b/tests/run-macros/tasty-macro-assert/quoted_1.scala @@ -33,8 +33,8 @@ object Asserts { tree match { case Inlined(_, Nil, Apply(Select(OpsTree(left), op), right :: Nil)) => op match { - case "===" => '{assertEquals(${left.seal}, ${right.seal})} - case "!==" => '{assertNotEquals(${left.seal}, ${right.seal})} + case "===" => '{assertEquals(${left.asExpr}, ${right.asExpr})} + case "!==" => '{assertNotEquals(${left.asExpr}, ${right.asExpr})} } case _ => '{assertTrue($cond)} diff --git a/tests/run-macros/tasty-unsafe-let/quoted_1.scala b/tests/run-macros/tasty-unsafe-let/quoted_1.scala index 3e578404bbe0..c6aab62eb007 100644 --- a/tests/run-macros/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-macros/tasty-unsafe-let/quoted_1.scala @@ -12,7 +12,7 @@ object Macros { import qctx.reflect._ ValDef.let(rhsTerm) { rhsId => - Expr.betaReduce('{$body(${rhsId.seal.asInstanceOf[Expr[T]]})}).unseal // Dangerous uncheked cast! + Expr.betaReduce('{$body(${rhsId.asExpr.asInstanceOf[Expr[T]]})}).unseal // Dangerous uncheked cast! }.asExprOf[Unit] } diff --git a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala index b771ae51b14c..8f4d63f04ae7 100644 --- a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala @@ -23,7 +23,7 @@ object XmlQuote { def liftListOfAny(lst: List[Term]): Expr[List[Any]] = lst match { case x :: xs => - val head = x.seal + val head = x.asExpr val tail = liftListOfAny(xs) '{ $head :: $tail } case Nil => '{Nil} diff --git a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala index 66e4b9f042f7..7ca06828f913 100644 --- a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala @@ -58,7 +58,7 @@ object XmlQuote { // [a0, ...]: Any* val args2: Expr[List[Any]] = args.unseal.underlyingArgument match { case Typed(Repeated(args0, _), _) => // statically known args, make list directly - Expr.ofList(args0.map(_.seal)) + Expr.ofList(args0.map(_.asExpr)) case _ => '{$args.toList}