File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
library/src-bootstrapped/scala/quoted Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,14 @@ object Liftable {
45
45
}
46
46
}
47
47
48
+ given ClassTagIsLiftable [T : Type ] as Liftable [ClassTag [T ]] = new Liftable [ClassTag [T ]] {
49
+ def toExpr (ct : ClassTag [T ]): given QuoteContext => Expr [ClassTag [T ]] =
50
+ ' { ClassTag [T ]($ {ct.runtimeClass.toExpr}) }
51
+ }
52
+
48
53
given ArrayIsLiftable [T : Type : Liftable : ClassTag ] as Liftable [Array [T ]] = new Liftable [Array [T ]] {
49
- def toExpr (arr : Array [T ]): given QuoteContext => Expr [Array [T ]] = ' {
50
- val array = new Array [T ]($ {arr.length.toExpr})(ClassTag ($ {the[ClassTag [T ]].runtimeClass.toExpr}))
51
- $ { Expr .block(List .tabulate(arr.length)(i => ' { array($ {i.toExpr}) = $ {arr(i).toExpr} }), ' { array }) }
52
- }
54
+ def toExpr (arr : Array [T ]): given QuoteContext => Expr [Array [T ]] =
55
+ ' { Array [T ]($ {arr.toSeq.toExpr}: _* )($ {the[ClassTag [T ]].toExpr}) }
53
56
}
54
57
55
58
given ArrayOfBooleanIsLiftable as Liftable [Array [Boolean ]] = new Liftable [Array [Boolean ]] {
You can’t perform that action at this time.
0 commit comments