Skip to content

Commit ea14aab

Browse files
committed
Replace PrimitiveExprs by the sinlge class ConstantExpr
1 parent a679194 commit ea14aab

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ object PickledQuotes {
2424
}
2525
}
2626

27-
/** Transform the expression into it's fully spliced Tree */
27+
/** Transform the expression into its fully spliced Tree */
2828
def quotedToTree(expr: quoted.Quoted)(implicit ctx: Context): Tree = expr match {
2929
case expr: quoted.TastyQuoted => unpickleQuote(expr)
30-
case expr: quoted.Liftable.PrimitiveExpr[_] => Literal(Constant(expr.value))
30+
case expr: quoted.Liftable.ConstantExpr[_] => Literal(Constant(expr.value))
3131
case expr: RawQuoted => expr.tree
3232
}
3333

library/src/scala/quoted/Liftable.scala

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,16 @@ abstract class Liftable[T] {
1414
*/
1515
object Liftable {
1616

17-
sealed abstract class PrimitiveExpr[T] extends Expr[T] {
18-
def value: T
19-
}
17+
final class ConstantExpr[T] private[Liftable](val value: T) extends Expr[T]
2018

21-
private class ValueExpr[T <: AnyVal](val value: T) extends PrimitiveExpr[T]
19+
implicit def BooleanIsLiftable: Liftable[Boolean] = (x: Boolean) => new ConstantExpr(x)
20+
implicit def ByteLiftable: Liftable[Byte] = (x: Byte) => new ConstantExpr(x)
21+
implicit def CharIsLiftable: Liftable[Char] = (x: Char) => new ConstantExpr(x)
22+
implicit def ShortIsLiftable: Liftable[Short] = (x: Short) => new ConstantExpr(x)
23+
implicit def IntIsLiftable: Liftable[Int] = (x: Int) => new ConstantExpr(x)
24+
implicit def LongIsLiftable: Liftable[Long] = (x: Long) => new ConstantExpr(x)
25+
implicit def FloatIsLiftable: Liftable[Float] = (x: Float) => new ConstantExpr(x)
26+
implicit def DoubleIsLiftable: Liftable[Double] = (x: Double) => new ConstantExpr(x)
2227

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)
31-
32-
private class StringExpr(val value: String) extends PrimitiveExpr[String]
33-
34-
implicit def StringIsLiftable: Liftable[String] = (x: String) => new StringExpr(x)
28+
implicit def StringIsLiftable: Liftable[String] = (x: String) => new ConstantExpr(x)
3529
}

0 commit comments

Comments
 (0)