Skip to content

Commit 38cc898

Browse files
committed
Rename TASTy reflection method to reflect/reify
1 parent 3cfbb6d commit 38cc898

File tree

23 files changed

+41
-37
lines changed

23 files changed

+41
-37
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/QuotedOpsImpl.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import dotty.tools.dotc.reporting.diagnostic.MessageContainer
88
trait QuotedOpsImpl extends scala.tasty.reflect.QuotedOps with TastyCoreImpl {
99

1010
def QuotedExprDeco[T](x: scala.quoted.Expr[T]): QuotedExprAPI = new QuotedExprAPI {
11-
def toTasty(implicit ctx: Context): Term = PickledQuotes.quotedExprToTree(x)
11+
def reflect(implicit ctx: Context): Term = PickledQuotes.quotedExprToTree(x)
1212
}
1313

1414
def QuotedTypeDeco[T](x: scala.quoted.Type[T]): QuotedTypeAPI = new QuotedTypeAPI {
15-
def toTasty(implicit ctx: Context): TypeTree = PickledQuotes.quotedTypeToTree(x)
15+
def reflect(implicit ctx: Context): TypeTree = PickledQuotes.quotedTypeToTree(x)
1616
}
1717

1818
def TermToQuoteDeco(term: Term): TermToQuotedAPI = new TermToQuotedAPI {
1919

20-
def toExpr[T: scala.quoted.Type](implicit ctx: Context): scala.quoted.Expr[T] = {
20+
def reify[T: scala.quoted.Type](implicit ctx: Context): scala.quoted.Expr[T] = {
2121
typecheck(ctx)
2222
new scala.quoted.Exprs.TastyTreeExpr(term).asInstanceOf[scala.quoted.Expr[T]]
2323
}
@@ -28,7 +28,7 @@ trait QuotedOpsImpl extends scala.tasty.reflect.QuotedOps with TastyCoreImpl {
2828
ctx0.typerState.setReporter(new Reporter {
2929
def doReport(m: MessageContainer)(implicit ctx: Context): Unit = ()
3030
})
31-
val tp = QuotedTypeDeco(implicitly[scala.quoted.Type[T]]).toTasty
31+
val tp = QuotedTypeDeco(implicitly[scala.quoted.Type[T]]).reflect
3232
ctx0.typer.typed(term, tp.tpe)
3333
if (ctx0.reporter.hasErrors) {
3434
val stack = new Exception().getStackTrace

library/src/scala/tasty/reflect/QuotedOps.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ package scala.tasty.reflect
44
trait QuotedOps extends TastyCore {
55

66
trait QuotedExprAPI {
7-
def toTasty(implicit ctx: Context): Term
7+
/** View this expression `Expr[T]` as a `Term` */
8+
def reflect(implicit ctx: Context): Term
89
}
910
implicit def QuotedExprDeco[T](expr: quoted.Expr[T]): QuotedExprAPI
1011

1112
trait QuotedTypeAPI {
12-
def toTasty(implicit ctx: Context): TypeTree
13+
/** View this expression `Type[T]` as a `TypeTree` */
14+
def reflect(implicit ctx: Context): TypeTree
1315
}
1416
implicit def QuotedTypeDeco[T](tpe: quoted.Type[T]): QuotedTypeAPI
1517

1618
trait TermToQuotedAPI {
17-
def toExpr[T: scala.quoted.Type](implicit ctx: Context): scala.quoted.Expr[T]
19+
/** Convert `Term` to an `Expr[T]` and check that it conforms to `T` */
20+
def reify[T: scala.quoted.Type](implicit ctx: Context): scala.quoted.Expr[T]
1821
}
1922
implicit def TermToQuoteDeco(term: Term): TermToQuotedAPI
2023

library/src/scala/tasty/util/ConstantExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ class ConstantExtractor[T <: Tasty with Singleton](val tasty: T) {
2525
case Term.Inlined(_, Nil, e) => const(e)
2626
case _ => None
2727
}
28-
const(expr.toTasty)
28+
const(expr.reflect)
2929
}
3030
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Asserts {
1717
def impl(cond: Expr[Boolean])(implicit tasty: Tasty): Expr[Unit] = {
1818
import tasty._
1919

20-
val tree = cond.toTasty
20+
val tree = cond.reflect
2121

2222
def isOps(tpe: TypeOrBounds): Boolean = tpe match {
2323
case Type.SymRef(IsDefSymbol(sym), _) => sym.name == "Ops" // TODO check that the parent is Asserts
@@ -34,7 +34,7 @@ object Asserts {
3434

3535
tree match {
3636
case Term.Inlined(_, Nil, Term.Apply(Term.Select(OpsTree(left), op, _), right :: Nil)) =>
37-
'(assertTrue(~left.toExpr[Boolean])) // Buggy code. To generate the errors
37+
'(assertTrue(~left.reify[Boolean])) // Buggy code. To generate the errors
3838
case _ =>
3939
'(assertTrue(~cond))
4040
}

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
@@ -13,7 +13,7 @@ object Foo {
1313
case IsValSymbol(sym) => sym.tree.show.toExpr
1414
case IsBindSymbol(sym) => sym.tree.show.toExpr
1515
}
16-
x.toTasty match {
16+
x.reflect match {
1717
case Term.Inlined(None, Nil, arg) => definitionString(arg)
1818
case arg => definitionString(arg) // TODO should all by name parameters be in an inline node?
1919
}

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
@@ -13,7 +13,7 @@ object Foo {
1313
case IsValSymbol(sym) => sym.tree.show.toExpr
1414
case IsBindSymbol(sym) => sym.tree.show.toExpr
1515
}
16-
x.toTasty match {
16+
x.reflect match {
1717
case Term.Inlined(None, Nil, arg) => definitionString(arg)
1818
case arg => definitionString(arg) // TODO should all by name parameters be in an inline node?
1919
}

tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object Macros {
4141
}
4242
}
4343

44-
val tree = x.toTasty
44+
val tree = x.reflect
4545
output.traverseTree(tree)
4646
'(print(~buff.result().toExpr))
4747
}

tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Foo {
1717
case _ => '("NO DEFINTION")
1818
}
1919

20-
x.toTasty match {
20+
x.reflect match {
2121
case Term.Inlined(None, Nil, arg) => definitionString(arg)
2222
case arg => definitionString(arg) // TODO should all by name parameters be in an inline node
2323
}

tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Foo {
1717
case _ => '("NO DEFINTION")
1818
}
1919

20-
x.toTasty match {
20+
x.reflect match {
2121
case Term.Inlined(None, Nil, arg) => definitionString(arg)
2222
case arg => definitionString(arg) // TODO should all by name parameters be in an inline node
2323
}

tests/run-separate-compilation/i5119/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ object Macro {
88
implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc)
99
def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(implicit tasty: Tasty): Expr[String] = {
1010
import tasty._
11-
(sc.toTasty.underlyingArgument.show + "\n" + args.toTasty.underlyingArgument.show).toExpr
11+
(sc.reflect.underlyingArgument.show + "\n" + args.reflect.underlyingArgument.show).toExpr
1212
}
1313
}

0 commit comments

Comments
 (0)