File tree Expand file tree Collapse file tree 5 files changed +48
-0
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 5 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,10 @@ class ReifyQuotes extends MacroTransform {
320
320
quotation(quotedTree, tree)
321
321
case Select (body, _) if tree.symbol.isSplice =>
322
322
splice(body, tree)
323
+ case tree : TypeTree if tree.tpe.typeSymbol.isSplice =>
324
+ // FIXME handle nested spliced type like TypeTree(List[t.unary_~])
325
+ val splicedType = tree.tpe.asInstanceOf [TypeRef ].prefix.termSymbol
326
+ splice(ref(splicedType), tree)
323
327
case Block (stats, _) =>
324
328
val last = enteredSyms
325
329
stats.foreach(markDef)
Original file line number Diff line number Diff line change
1
+ {
2
+ dotty.runtime.Arrays.newGenericArray[Int](3)(reflect.ClassTag.Int)
3
+ }
Original file line number Diff line number Diff line change
1
+ import dotty .tools .dotc .quoted .Runners ._
2
+ import scala .quoted ._
3
+ import scala .reflect .ClassTag
4
+
5
+ object Arrays {
6
+ implicit def ArrayIsLiftable [T : Liftable ](implicit t : Type [T ], ct : Expr [ClassTag [T ]]): Liftable [Array [List [T ]]] = (arr : Array [List [T ]]) => ' {
7
+ new Array [List [~ t]](~ (arr.length: Expr [Int ]))
8
+ // TODO add elements
9
+ }
10
+ }
11
+
12
+ object Test {
13
+ def main (args : Array [String ]): Unit = {
14
+ import Arrays ._
15
+ implicit val ct : Expr [ClassTag [Int ]] = '(ClassTag.Int)
16
+ val arr : Expr [Array [List [Int ]]] = Array [List [Int ]](List (1 , 2 , 3 ))
17
+ println(arr.show)
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ dotty.runtime.Arrays.newGenericArray[Int](3)(reflect.ClassTag.Int)
3
+ }
Original file line number Diff line number Diff line change
1
+ import dotty .tools .dotc .quoted .Runners ._
2
+ import scala .quoted ._
3
+ import scala .reflect .ClassTag
4
+
5
+ object Arrays {
6
+ implicit def ArrayIsLiftable [T : Liftable ](implicit t : Type [T ], ct : Expr [ClassTag [T ]]): Liftable [Array [T ]] = (arr : Array [T ]) => ' {
7
+ new Array [~ t](~ (arr.length: Expr [Int ]))(~ ct)
8
+ // TODO add elements
9
+ }
10
+ }
11
+
12
+ object Test {
13
+ def main (args : Array [String ]): Unit = {
14
+ import Arrays ._
15
+ implicit val ct : Expr [ClassTag [Int ]] = '(ClassTag.Int)
16
+ val arr : Expr [Array [Int ]] = Array [Int ](1 , 2 , 3 )
17
+ println(arr.show)
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments