Skip to content

Commit 5d46d33

Browse files
committed
Remove asTree
1 parent 53f0bcc commit 5d46d33

File tree

29 files changed

+35
-44
lines changed

29 files changed

+35
-44
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
8080
object reflect extends reflectModule:
8181

8282
extension (expr: Expr[Any]):
83-
def asTree: Tree = expr.asTerm
8483
def asTerm: Term =
8584
val exprImpl = expr.asInstanceOf[ExprImpl]
8685
exprImpl.checkScopeId(QuotesImpl.this.hashCode)

library/src/scala/quoted/Quotes.scala

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
7979
* import scala.quoted._
8080
* def f(expr: Expr[Int])(using Quotes) =
8181
* import quotes.reflect._
82-
* val ast: Term = expr.asTerm // or `expr.asTree`
82+
* val ast: Term = expr.asTerm
8383
* ...
8484
* ```
8585
*
@@ -204,18 +204,10 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
204204
*/
205205
trait reflectModule { self: reflect.type =>
206206

207-
extension (expr: Expr[Any]):
208-
209-
/** Returns the `Tree` representation this expression.
210-
* Same as `asTerm` but typed as a `Tree`.
211-
*/
212-
def asTree: Tree
213-
214-
/** Returns the `Term` representation this expression */
207+
/** Returns the `Term` representation this expression */
208+
extension (expr: Expr[Any])
215209
def asTerm: Term
216210

217-
end extension
218-
219211
///////////////
220212
// TREES //
221213
///////////////
@@ -229,8 +221,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
229221
/** Methods of the module object `val Tree` */
230222
trait TreeModule { this: Tree.type =>
231223
/** Returns the Term representation this expression */
232-
@deprecated("Use `expr.asTree` instead (must `import quotes.reflect._`). This will be removed in 3.0.0-RC1", "3.0.0-M3")
233-
def of(expr: Expr[Any]): Tree = expr.asTree
224+
@deprecated("Use `expr.asTerm` instead (must `import quotes.reflect._`). This will be removed in 3.0.0-RC1", "3.0.0-M3")
225+
def of(expr: Expr[Any]): Tree = expr.asTerm
234226
}
235227

236228
/** Makes extension methods on `Tree` available without any imports */

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-
report.error(s, part.asTree.pos)
13+
report.error(s, part.asTerm.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-
report.error(s, part.asTree.pos)
13+
report.error(s, part.asTerm.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: Quotes) : Expr[Any] = {
99
import ctx.reflect._
10-
body.asTree match { case Block(_, _) => '{2} }
10+
body.asTerm 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
@@ -6,7 +6,7 @@ trait Show[T] {
66

77
def showInterpolatorImpl(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using Quotes): Expr[String] =
88
import quotes.reflect._
9-
argsExpr.asTree match
9+
argsExpr.asTerm match
1010
case '{ $arg: $t } => // error
1111
case '[ Int ] => // error
1212
???

tests/neg-macros/i9801/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ def impl(prog: Expr[Double])(using Quotes) : Expr[Double] =
1616
triggerStackOverflow(0)
1717
} catch {
1818
case e =>
19-
quotes.reflect.report.error(e.getMessage, prog.asTree.pos)
19+
quotes.reflect.report.error(e.getMessage, prog.asTerm.pos)
2020
'{ 42.0 }
2121
}

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 Quotes) : Expr[Unit] = {
1616
import quotes.reflect._
1717

18-
val tree = cond.asTree
18+
val tree = cond.asTerm
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 Quotes) : Expr[Unit] = {
1616
import quotes.reflect._
1717

18-
val tree = cond.asTree
18+
val tree = cond.asTerm
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/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 Quotes) : Expr[Unit] = {
1010
import quotes.reflect._
1111

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

0 commit comments

Comments
 (0)