Skip to content

Commit 3340db1

Browse files
committed
Add missing non-bootstraped toExpr
1 parent f557996 commit 3340db1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

library/src-non-bootstrapped/scala/quoted/package.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ package object quoted {
88
def withQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T =
99
throw new Exception("Non bootsrapped library")
1010

11+
implicit object ExprOps {
12+
def (x: T) toExpr[T: Liftable] given QuoteContext: Expr[T] = the[Liftable[T]].toExpr(x)
13+
}
1114
}

library/src/scala/quoted/Liftable.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ object Liftable {
4747

4848
given [T: Type: Liftable: ClassTag] as Liftable[IArray[T]] = new Liftable[IArray[T]] {
4949
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]] }) }
5252
}
5353
}
5454

5555
given [T: Type: Liftable] as Liftable[List[T]] = new Liftable[List[T]] {
5656
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}) }
5858
case Nil => '{ Nil: List[T] }
5959
}
6060
}

0 commit comments

Comments
 (0)