File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
src-non-bootstrapped/scala/quoted Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,7 @@ package object quoted {
8
8
def withQuoteContext [T ](thunk : given QuoteContext => T ) given (toolbox : Toolbox ): T =
9
9
throw new Exception (" Non bootsrapped library" )
10
10
11
+ implicit object ExprOps {
12
+ def (x : T ) toExpr[T : Liftable ] given QuoteContext : Expr [T ] = the[Liftable [T ]].toExpr(x)
13
+ }
11
14
}
Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ object Liftable {
47
47
48
48
given [T : Type : Liftable : ClassTag ] as Liftable [IArray [T ]] = new Liftable [IArray [T ]] {
49
49
def toExpr (iarray : IArray [T ]): given QuoteContext => Expr [IArray [T ]] = ' {
50
- val array = new Array [T ]($ {Liftable_Int_delegate .toExpr( iarray.length) })(ClassTag ($ {ClassIsLiftable .toExpr( the[ClassTag [T ]].runtimeClass) }))
51
- $ { Expr .block(List .tabulate(iarray.length)(i => ' { array($ {Liftable_Int_delegate .toExpr(i) }) = $ {the[ Liftable [ T ]].toExpr( iarray(i)) } }), ' { array.asInstanceOf [IArray [T ]] }) }
50
+ val array = new Array [T ]($ {iarray.length.toExpr })(ClassTag ($ {the[ClassTag [T ]].runtimeClass.toExpr }))
51
+ $ { Expr .block(List .tabulate(iarray.length)(i => ' { array($ {i .toExpr}) = $ {iarray(i).toExpr } }), ' { array.asInstanceOf [IArray [T ]] }) }
52
52
}
53
53
}
54
54
55
55
given [T : Type : Liftable ] as Liftable [List [T ]] = new Liftable [List [T ]] {
56
56
def toExpr (x : List [T ]): given QuoteContext => Expr [List [T ]] = x match {
57
- case x :: xs => ' { ($ {this .toExpr(xs) }).:: [T ]($ {the[ Liftable [ T ]] .toExpr(x) }) }
57
+ case x :: xs => ' { ($ {xs .toExpr}).:: [T ]($ {x .toExpr}) }
58
58
case Nil => ' { Nil : List [T ] }
59
59
}
60
60
}
You can’t perform that action at this time.
0 commit comments