Skip to content

Commit 75a813f

Browse files
committed
Rename ValueExpr to LiftedExpr
1 parent 4284363 commit 75a813f

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,6 @@ class Definitions {
628628
lazy val QuotedExprsModule = ctx.requiredModule("scala.quoted.Exprs")
629629
def QuotedExprsClass(implicit ctx: Context) = QuotedExprsModule.symbol.asClass
630630

631-
lazy val QuotedExprs_valueExprR = QuotedExprsModule.requiredMethod("valueExpr")
632-
def QuotedExprs_valueExpr(implicit ctx: Context) = QuotedExprs_valueExprR.symbol
633-
634631
lazy val QuotedTypeType = ctx.requiredClassRef("scala.quoted.Type")
635632
def QuotedTypeClass(implicit ctx: Context) = QuotedTypeType.symbol.asClass
636633

@@ -642,6 +639,7 @@ class Definitions {
642639
def QuotedType_apply(implicit ctx: Context) = QuotedType_applyR.symbol
643640

644641
def Unpickler_unpickleExpr = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleExpr")
642+
def Unpickler_liftedExpr = ctx.requiredMethod("scala.runtime.quoted.Unpickler.liftedExpr")
645643
def Unpickler_unpickleType = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleType")
646644

647645
lazy val EqType = ctx.requiredClassRef("scala.Eq")

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object PickledQuotes {
3333
/** Transform the expression into its fully spliced Tree */
3434
def quotedExprToTree(expr: quoted.Expr[_])(implicit ctx: Context): Tree = expr match {
3535
case expr: TastyExpr[_] => unpickleExpr(expr)
36-
case expr: ValueExpr[_] => Literal(Constant(expr.value))
36+
case expr: LiftedExpr[_] => Literal(Constant(expr.value))
3737
case expr: TreeExpr[Tree] @unchecked => expr.tree
3838
case expr: FunctionAppliedTo[_, _] =>
3939
functionAppliedTo(quotedExprToTree(expr.f), quotedExprToTree(expr.x))

compiler/src/dotty/tools/dotc/quoted/Toolbox.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import dotty.tools.dotc.ast.Trees._
44
import dotty.tools.dotc.ast.tpd
55
import dotty.tools.dotc.core.Constants._
66
import dotty.tools.dotc.printing.RefinedPrinter
7-
import dotty.tools.dotc.transform.ReifyQuotes
87

98
import scala.quoted.Expr
109
import scala.runtime.BoxedUnit
11-
import scala.quoted.Exprs.ValueExpr
10+
import scala.quoted.Exprs.LiftedExpr
1211
import scala.runtime.quoted._
1312

1413
/** Default runners for quoted expressions */
@@ -24,12 +23,12 @@ object Toolbox {
2423
): Toolbox[T] = new Toolbox[T] {
2524

2625
def run(expr: Expr[T]): T = expr match {
27-
case expr: ValueExpr[T] => expr.value
26+
case expr: LiftedExpr[T] => expr.value
2827
case _ => new QuoteDriver().run(expr, runSettings)
2928
}
3029

3130
def show(expr: Expr[T]): String = expr match {
32-
case expr: ValueExpr[T] =>
31+
case expr: LiftedExpr[T] =>
3332
implicit val ctx = new QuoteDriver().initCtx
3433
if (showSettings.compilerArgs.contains("-color:never"))
3534
ctx.settings.color.update("never")
@@ -47,7 +46,7 @@ object Toolbox {
4746
case _ => None
4847
}
4948
expr match {
50-
case expr: ValueExpr[T] => Some(expr.value)
49+
case expr: LiftedExpr[T] => Some(expr.value)
5150
case _ => new QuoteDriver().withTree(expr, (tree, _) => toConstantOpt(tree), Settings.run())
5251
}
5352
}

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
297297

298298
private def pickledQuote(body: Tree, splices: List[Tree], isType: Boolean)(implicit ctx: Context) = {
299299
def pickleAsValue[T](value: T) =
300-
ref(defn.QuotedExprs_valueExpr).appliedToType(body.tpe.widen).appliedTo(Literal(Constant(value)))
300+
ref(defn.Unpickler_liftedExpr).appliedToType(body.tpe.widen).appliedTo(Literal(Constant(value)))
301301
def pickleAsTasty() = {
302302
val meth =
303303
if (isType) ref(defn.Unpickler_unpickleType).appliedToType(body.tpe)

library/src/scala/quoted/Expr.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ object Exprs {
2828
override def toString(): String = s"Expr(<pickled>)"
2929
}
3030

31-
/** An Expr backed by a value.
31+
/** An Expr backed by a lifted value.
3232
* Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null.
3333
*/
34-
final class ValueExpr[T](val value: T) extends Expr[T] {
34+
final class LiftedExpr[T](val value: T) extends Expr[T] {
3535
override def toString: String = s"Expr($value)"
3636
}
3737

38-
def valueExpr[T](value: T): ValueExpr[T] = new ValueExpr[T](value)
39-
4038
/** An Expr backed by a tree. Only the current compiler trees are allowed. */
4139
final class TreeExpr[Tree](val tree: Tree) extends quoted.Expr[Any] {
4240
override def toString: String = s"Expr(<raw>)"

library/src/scala/quoted/Liftable.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.quoted
22

3-
import scala.quoted.Exprs.ValueExpr
3+
import scala.runtime.quoted.Unpickler.liftedExpr
44

55
/** A typeclass for types that can be turned to `quoted.Expr[T]`
66
* without going through an explicit `'(...)` operation.
@@ -20,14 +20,14 @@ object Liftable {
2020
def toExpr(implicit liftable: Liftable[T]): Expr[T] = liftable.toExpr(x)
2121
}
2222

23-
implicit def BooleanIsLiftable: Liftable[Boolean] = (x: Boolean) => new ValueExpr(x)
24-
implicit def ByteLiftable: Liftable[Byte] = (x: Byte) => new ValueExpr(x)
25-
implicit def CharIsLiftable: Liftable[Char] = (x: Char) => new ValueExpr(x)
26-
implicit def ShortIsLiftable: Liftable[Short] = (x: Short) => new ValueExpr(x)
27-
implicit def IntIsLiftable: Liftable[Int] = (x: Int) => new ValueExpr(x)
28-
implicit def LongIsLiftable: Liftable[Long] = (x: Long) => new ValueExpr(x)
29-
implicit def FloatIsLiftable: Liftable[Float] = (x: Float) => new ValueExpr(x)
30-
implicit def DoubleIsLiftable: Liftable[Double] = (x: Double) => new ValueExpr(x)
23+
implicit def BooleanIsLiftable: Liftable[Boolean] = (x: Boolean) => liftedExpr(x)
24+
implicit def ByteLiftable: Liftable[Byte] = (x: Byte) => liftedExpr(x)
25+
implicit def CharIsLiftable: Liftable[Char] = (x: Char) => liftedExpr(x)
26+
implicit def ShortIsLiftable: Liftable[Short] = (x: Short) => liftedExpr(x)
27+
implicit def IntIsLiftable: Liftable[Int] = (x: Int) => liftedExpr(x)
28+
implicit def LongIsLiftable: Liftable[Long] = (x: Long) => liftedExpr(x)
29+
implicit def FloatIsLiftable: Liftable[Float] = (x: Float) => liftedExpr(x)
30+
implicit def DoubleIsLiftable: Liftable[Double] = (x: Double) => liftedExpr(x)
3131

32-
implicit def StringIsLiftable: Liftable[String] = (x: String) => new ValueExpr(x)
32+
implicit def StringIsLiftable: Liftable[String] = (x: String) => liftedExpr(x)
3333
}

library/src/scala/runtime/quoted/Unpickler.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package scala.runtime.quoted
22

33
import scala.quoted.Types.TastyType
4-
import scala.quoted.Exprs.TastyExpr
4+
import scala.quoted.Exprs.{LiftedExpr, TastyExpr}
55
import scala.quoted.{Expr, Type}
66

77
/** Provides methods to unpickle `Expr` and `Type` trees. */
@@ -17,6 +17,11 @@ object Unpickler {
1717
*/
1818
def unpickleExpr[T](repr: Pickled, args: Seq[Any]): Expr[T] = new TastyExpr[T](repr, args)
1919

20+
/** Lift the `value` to an `Expr` tree.
21+
* Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null.
22+
*/
23+
def liftedExpr[T](value: T): LiftedExpr[T] = new LiftedExpr[T](value)
24+
2025
/** Unpickle `repr` which represents a pickled `Type` tree,
2126
* replacing splice nodes with `args`
2227
*/
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
class scala.quoted.Exprs$ValueExpr
2-
class scala.quoted.Exprs$ValueExpr
3-
class scala.quoted.Exprs$ValueExpr
4-
class scala.quoted.Exprs$ValueExpr
5-
class scala.quoted.Exprs$ValueExpr
6-
class scala.quoted.Exprs$ValueExpr
7-
class scala.quoted.Exprs$ValueExpr
8-
class scala.quoted.Exprs$ValueExpr
9-
class scala.quoted.Exprs$ValueExpr
10-
class scala.quoted.Exprs$ValueExpr
11-
class scala.quoted.Exprs$ValueExpr
12-
class scala.quoted.Exprs$ValueExpr
13-
class scala.quoted.Exprs$ValueExpr
14-
class scala.quoted.Exprs$ValueExpr
15-
class scala.quoted.Exprs$ValueExpr
1+
class scala.quoted.Exprs$LiftedExpr
2+
class scala.quoted.Exprs$LiftedExpr
3+
class scala.quoted.Exprs$LiftedExpr
4+
class scala.quoted.Exprs$LiftedExpr
5+
class scala.quoted.Exprs$LiftedExpr
6+
class scala.quoted.Exprs$LiftedExpr
7+
class scala.quoted.Exprs$LiftedExpr
8+
class scala.quoted.Exprs$LiftedExpr
9+
class scala.quoted.Exprs$LiftedExpr
10+
class scala.quoted.Exprs$LiftedExpr
11+
class scala.quoted.Exprs$LiftedExpr
12+
class scala.quoted.Exprs$LiftedExpr
13+
class scala.quoted.Exprs$LiftedExpr
14+
class scala.quoted.Exprs$LiftedExpr
15+
class scala.quoted.Exprs$LiftedExpr

0 commit comments

Comments
 (0)