File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed
compiler/src/dotty/tools/dotc/quoted Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ object PickledQuotes {
2727 /** Transform the expression into it's 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.ValueExpr [_] => Literal (Constant (expr.value))
30+ case expr : quoted.Liftable . PrimitiveExpr [_] => Literal (Constant (expr.value))
3131 case expr : RawQuoted => expr.tree
3232 }
3333
Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ abstract class Liftable[T] {
1313 * gives an alternative implementation using just the basic staging system.
1414 */
1515object Liftable {
16+
17+ sealed abstract class PrimitiveExpr [T ] extends Expr [T ] {
18+ def value : T
19+ }
20+
21+ private class ValueExpr [T <: AnyVal ](val value : T ) extends PrimitiveExpr [T ]
22+
1623 implicit def BooleanIsLiftable : Liftable [Boolean ] = (x : Boolean ) => new ValueExpr (x)
1724 implicit def ByteLiftable : Liftable [Byte ] = (x : Byte ) => new ValueExpr (x)
1825 implicit def CharIsLiftable : Liftable [Char ] = (x : Char ) => new ValueExpr (x)
@@ -21,4 +28,8 @@ object Liftable {
2128 implicit def LongIsLiftable : Liftable [Long ] = (x : Long ) => new ValueExpr (x)
2229 implicit def FloatIsLiftable : Liftable [Float ] = (x : Float ) => new ValueExpr (x)
2330 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)
2435}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ object Test {
3232 (1L : Expr [Long ])
3333 (1.0f : Expr [Float ])
3434 (1.0 : Expr [Double ])
35+ (" abc" : Expr [String ])
3536
3637 val xs : Expr [List [Int ]] = 1 :: 2 :: 3 :: Nil
3738}
You can’t perform that action at this time.
0 commit comments