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 {
27
27
/** Transform the expression into it's fully spliced Tree */
28
28
def quotedToTree (expr : quoted.Quoted )(implicit ctx : Context ): Tree = expr match {
29
29
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))
31
31
case expr : RawQuoted => expr.tree
32
32
}
33
33
Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ abstract class Liftable[T] {
13
13
* gives an alternative implementation using just the basic staging system.
14
14
*/
15
15
object 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
+
16
23
implicit def BooleanIsLiftable : Liftable [Boolean ] = (x : Boolean ) => new ValueExpr (x)
17
24
implicit def ByteLiftable : Liftable [Byte ] = (x : Byte ) => new ValueExpr (x)
18
25
implicit def CharIsLiftable : Liftable [Char ] = (x : Char ) => new ValueExpr (x)
@@ -21,4 +28,8 @@ object Liftable {
21
28
implicit def LongIsLiftable : Liftable [Long ] = (x : Long ) => new ValueExpr (x)
22
29
implicit def FloatIsLiftable : Liftable [Float ] = (x : Float ) => new ValueExpr (x)
23
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)
24
35
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ object Test {
32
32
(1L : Expr [Long ])
33
33
(1.0f : Expr [Float ])
34
34
(1.0 : Expr [Double ])
35
+ (" abc" : Expr [String ])
35
36
36
37
val xs : Expr [List [Int ]] = 1 :: 2 :: 3 :: Nil
37
38
}
You can’t perform that action at this time.
0 commit comments