@@ -8,7 +8,7 @@ import scala.reflect.ClassTag
88trait Liftable [T ] {
99
1010 /** Lift a value into an expression containing the construction of that value */
11- def toExpr (x : T ): delegate QuoteContext => Expr [T ]
11+ def toExpr (x : T ): ( given QuoteContext ) => Expr [T ]
1212
1313}
1414
@@ -31,112 +31,112 @@ object Liftable {
3131
3232 private class PrimitiveLiftable [T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String ] extends Liftable [T ] {
3333 /** Lift a primitive value `n` into `'{ n }` */
34- def toExpr (x : T ) = delegate qctx => {
34+ def toExpr (x : T ) = ( given qctx ) => {
3535 import qctx .tasty ._
3636 Literal (Constant (x)).seal.asInstanceOf [Expr [T ]]
3737 }
3838 }
3939
4040 given ClassIsLiftable [T ] as Liftable [Class [T ]] = new Liftable [Class [T ]] {
4141 /** Lift a `Class[T]` into `'{ classOf[T] }` */
42- def toExpr (x : Class [T ]) = delegate qctx => {
42+ def toExpr (x : Class [T ]) = ( given qctx ) => {
4343 import qctx .tasty ._
4444 Ref (defn.Predef_classOf ).appliedToType(Type (x)).seal.asInstanceOf [Expr [Class [T ]]]
4545 }
4646 }
4747
4848 given ClassTagIsLiftable [T : Type ] as Liftable [ClassTag [T ]] = new Liftable [ClassTag [T ]] {
49- def toExpr (ct : ClassTag [T ]): delegate QuoteContext => Expr [ClassTag [T ]] =
49+ def toExpr (ct : ClassTag [T ]): ( given QuoteContext ) => Expr [ClassTag [T ]] =
5050 ' { ClassTag [T ]($ {ct.runtimeClass.toExpr}) }
5151 }
5252
5353 given ArrayIsLiftable [T : Type : Liftable : ClassTag ] as Liftable [Array [T ]] = new Liftable [Array [T ]] {
54- def toExpr (arr : Array [T ]): delegate QuoteContext => Expr [Array [T ]] =
54+ def toExpr (arr : Array [T ]): ( given QuoteContext ) => Expr [Array [T ]] =
5555 ' { Array [T ]($ {arr.toSeq.toExpr}: _* )($ {summon[ClassTag [T ]].toExpr}) }
5656 }
5757
5858 given ArrayOfBooleanIsLiftable as Liftable [Array [Boolean ]] = new Liftable [Array [Boolean ]] {
59- def toExpr (array : Array [Boolean ]): delegate QuoteContext => Expr [Array [Boolean ]] =
59+ def toExpr (array : Array [Boolean ]): ( given QuoteContext ) => Expr [Array [Boolean ]] =
6060 if (array.length == 0 ) ' { Array .emptyBooleanArray }
6161 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
6262 }
6363
6464 given ArrayOfByteIsLiftable as Liftable [Array [Byte ]] = new Liftable [Array [Byte ]] {
65- def toExpr (array : Array [Byte ]): delegate QuoteContext => Expr [Array [Byte ]] =
65+ def toExpr (array : Array [Byte ]): ( given QuoteContext ) => Expr [Array [Byte ]] =
6666 if (array.length == 0 ) ' { Array .emptyByteArray }
6767 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
6868 }
6969
7070 given ArrayOfShortIsLiftable as Liftable [Array [Short ]] = new Liftable [Array [Short ]] {
71- def toExpr (array : Array [Short ]): delegate QuoteContext => Expr [Array [Short ]] =
71+ def toExpr (array : Array [Short ]): ( given QuoteContext ) => Expr [Array [Short ]] =
7272 if (array.length == 0 ) ' { Array .emptyShortArray }
7373 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
7474 }
7575
7676 given ArrayOfCharIsLiftable as Liftable [Array [Char ]] = new Liftable [Array [Char ]] {
77- def toExpr (array : Array [Char ]): delegate QuoteContext => Expr [Array [Char ]] =
77+ def toExpr (array : Array [Char ]): ( given QuoteContext ) => Expr [Array [Char ]] =
7878 if (array.length == 0 ) ' { Array .emptyCharArray }
7979 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
8080 }
8181
8282 given ArrayOfIntIsLiftable as Liftable [Array [Int ]] = new Liftable [Array [Int ]] {
83- def toExpr (array : Array [Int ]): delegate QuoteContext => Expr [Array [Int ]] =
83+ def toExpr (array : Array [Int ]): ( given QuoteContext ) => Expr [Array [Int ]] =
8484 if (array.length == 0 ) ' { Array .emptyIntArray }
8585 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
8686 }
8787
8888 given ArrayOfLongIsLiftable as Liftable [Array [Long ]] = new Liftable [Array [Long ]] {
89- def toExpr (array : Array [Long ]): delegate QuoteContext => Expr [Array [Long ]] =
89+ def toExpr (array : Array [Long ]): ( given QuoteContext ) => Expr [Array [Long ]] =
9090 if (array.length == 0 ) ' { Array .emptyLongArray }
9191 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
9292 }
9393
9494 given ArrayOfFloatIsLiftable as Liftable [Array [Float ]] = new Liftable [Array [Float ]] {
95- def toExpr (array : Array [Float ]): delegate QuoteContext => Expr [Array [Float ]] =
95+ def toExpr (array : Array [Float ]): ( given QuoteContext ) => Expr [Array [Float ]] =
9696 if (array.length == 0 ) ' { Array .emptyFloatArray }
9797 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
9898 }
9999
100100 given ArrayOfDoubleIsLiftable as Liftable [Array [Double ]] = new Liftable [Array [Double ]] {
101- def toExpr (array : Array [Double ]): delegate QuoteContext => Expr [Array [Double ]] =
101+ def toExpr (array : Array [Double ]): ( given QuoteContext ) => Expr [Array [Double ]] =
102102 if (array.length == 0 ) ' { Array .emptyDoubleArray }
103103 else ' { Array ($ {array(0 ).toExpr}, $ {array.toSeq.tail.toExpr}: _* ) }
104104 }
105105
106106 given IArrayIsLiftable [T : Type ] as Liftable [IArray [T ]] given (ltArray : Liftable [Array [T ]]) = new Liftable [IArray [T ]] {
107- def toExpr (iarray : IArray [T ]): delegate QuoteContext => Expr [IArray [T ]] =
107+ def toExpr (iarray : IArray [T ]): ( given QuoteContext ) => Expr [IArray [T ]] =
108108 ' { $ {ltArray.toExpr(iarray.asInstanceOf [Array [T ]])}.asInstanceOf [IArray [T ]] }
109109 }
110110
111111 given [T : Type : Liftable ] as Liftable [Seq [T ]] = new Liftable [Seq [T ]] {
112- def toExpr (xs : Seq [T ]): delegate QuoteContext => Expr [Seq [T ]] =
112+ def toExpr (xs : Seq [T ]): ( given QuoteContext ) => Expr [Seq [T ]] =
113113 xs.map(summon[Liftable [T ]].toExpr).toExprOfSeq
114114 }
115115
116116 given [T : Type : Liftable ] as Liftable [List [T ]] = new Liftable [List [T ]] {
117- def toExpr (xs : List [T ]): delegate QuoteContext => Expr [List [T ]] =
117+ def toExpr (xs : List [T ]): ( given QuoteContext ) => Expr [List [T ]] =
118118 xs.map(summon[Liftable [T ]].toExpr).toExprOfList
119119 }
120120
121121 given [T : Type : Liftable ] as Liftable [Set [T ]] = new Liftable [Set [T ]] {
122- def toExpr (set : Set [T ]): delegate QuoteContext => Expr [Set [T ]] =
122+ def toExpr (set : Set [T ]): ( given QuoteContext ) => Expr [Set [T ]] =
123123 ' { Set ($ {set.toSeq.toExpr}: _* ) }
124124 }
125125
126126 given [T : Type : Liftable , U : Type : Liftable ] as Liftable [Map [T , U ]] = new Liftable [Map [T , U ]] {
127- def toExpr (map : Map [T , U ]): delegate QuoteContext => Expr [Map [T , U ]] =
127+ def toExpr (map : Map [T , U ]): ( given QuoteContext ) => Expr [Map [T , U ]] =
128128 ' { Map ($ {map.toSeq.toExpr}: _* ) }
129129 }
130130
131131 given [T : Type : Liftable ] as Liftable [Option [T ]] = new Liftable [Option [T ]] {
132- def toExpr (x : Option [T ]): delegate QuoteContext => Expr [Option [T ]] = x match {
132+ def toExpr (x : Option [T ]): ( given QuoteContext ) => Expr [Option [T ]] = x match {
133133 case Some (x) => ' { Some [T ]($ {x.toExpr}) }
134134 case None => ' { None : Option [T ] }
135135 }
136136 }
137137
138138 given [L : Type : Liftable , R : Type : Liftable ] as Liftable [Either [L , R ]] = new Liftable [Either [L , R ]] {
139- def toExpr (x : Either [L , R ]): delegate QuoteContext => Expr [Either [L , R ]] = x match {
139+ def toExpr (x : Either [L , R ]): ( given QuoteContext ) => Expr [Either [L , R ]] = x match {
140140 case Left (x) => ' { Left [L , R ]($ {x.toExpr}) }
141141 case Right (x) => ' { Right [L , R ]($ {x.toExpr}) }
142142 }
@@ -289,19 +289,19 @@ object Liftable {
289289 }
290290
291291 given [H : Type : Liftable , T <: Tuple : Type : Liftable ] as Liftable [H *: T ] = new {
292- def toExpr (tup : H *: T ): delegate QuoteContext => Expr [H *: T ] =
292+ def toExpr (tup : H *: T ): ( given QuoteContext ) => Expr [H *: T ] =
293293 ' { $ {summon[Liftable [H ]].toExpr(tup.head)} *: $ {summon[Liftable [T ]].toExpr(tup.tail)} }
294294 // '{ ${tup.head.toExpr} *: ${tup.tail.toExpr} } // TODO figure out why this fails during CI documentation
295295 }
296296
297297 given as Liftable [BigInt ] = new Liftable [BigInt ] {
298- def toExpr (x : BigInt ): delegate QuoteContext => Expr [BigInt ] =
298+ def toExpr (x : BigInt ): ( given QuoteContext ) => Expr [BigInt ] =
299299 ' { BigInt ($ {x.toByteArray.toExpr}) }
300300 }
301301
302302 /** Lift a BigDecimal using the default MathContext */
303303 given as Liftable [BigDecimal ] = new Liftable [BigDecimal ] {
304- def toExpr (x : BigDecimal ): delegate QuoteContext => Expr [BigDecimal ] =
304+ def toExpr (x : BigDecimal ): ( given QuoteContext ) => Expr [BigDecimal ] =
305305 ' { BigDecimal ($ {x.toString.toExpr}) }
306306 }
307307
0 commit comments