From 9479f54adc6fb7350745f5727da22cc45aefca14 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 5 Feb 2020 15:29:23 +0100 Subject: [PATCH 1/4] Update given syntax --- library/src/scala/quoted/Expr.scala | 30 +++--- library/src/scala/quoted/Liftable.scala | 48 ++++----- library/src/scala/quoted/Type.scala | 22 ++-- library/src/scala/quoted/ValueOfExpr.scala | 102 +++++++++--------- library/src/scala/quoted/autolift.scala | 2 +- library/src/scala/quoted/matching/Const.scala | 2 +- .../src/scala/quoted/matching/ConstSeq.scala | 4 +- .../src/scala/quoted/matching/ExprSeq.scala | 4 +- library/src/scala/quoted/matching/Value.scala | 2 +- .../src/scala/quoted/matching/ValueSeq.scala | 4 +- .../src/scala/quoted/matching/package.scala | 2 +- library/src/scala/quoted/util/ExprMap.scala | 32 +++--- library/src/scala/quoted/util/Var.scala | 10 +- 13 files changed, 132 insertions(+), 132 deletions(-) diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index ed1a3bf6a0b0..d243c9af3afa 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -16,14 +16,14 @@ class Expr[+T] private[scala] { * Returns `None` if the expression does not contain a value or contains side effects. * Otherwise returns the `Some` of the value. */ - final def getValue[U >: T](given qctx: QuoteContext, valueOf: ValueOfExpr[U]): Option[U] = valueOf(this) + final def getValue[U >: T](using qctx: QuoteContext, valueOf: ValueOfExpr[U]): Option[U] = valueOf(this) /** Return the value of this expression. * * Emits an error error and throws if the expression does not contain a value or contains side effects. * Otherwise returns the value. */ - final def value[U >: T](given qctx: QuoteContext, valueOf: ValueOfExpr[U]): U = + final def value[U >: T](using qctx: QuoteContext, valueOf: ValueOfExpr[U]): U = valueOf(this).getOrElse(qctx.throwError(s"Expected a known value. \n\nThe value of: $show\ncould not be recovered using $valueOf", this)) /** Pattern matches `this` against `that`. Effectively performing a deep equality check. @@ -34,7 +34,7 @@ class Expr[+T] private[scala] { * case _ => false * ``` */ - final def matches(that: Expr[Any])(given qctx: QuoteContext): Boolean = + final def matches(that: Expr[Any])(using qctx: QuoteContext): Boolean = !scala.internal.quoted.Expr.unapply[Unit, Unit](this)(given that, false, qctx).isEmpty } @@ -42,7 +42,7 @@ class Expr[+T] private[scala] { object Expr { /** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */ - type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, [X] =>> (given QuoteContext) => Expr[X]] + type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, [X] =>> QuoteContext ?=> Expr[X]] /** `Expr.betaReduce(f)(x1, ..., xn)` is functionally the same as `'{($f)($x1, ..., $xn)}`, however it optimizes this call * by returning the result of beta-reducing `f(x1, ..., xn)` if `f` is a known lambda expression. @@ -52,7 +52,7 @@ object Expr { * Expr.betaReduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) * ``` */ - def betaReduce[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { + def betaReduce[F, Args <: Tuple, R, G](f: Expr[F])(using tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { import qctx.tasty.{_, given} tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } @@ -62,22 +62,22 @@ object Expr { * * `Expr.betaReduceGiven` distributes applications of `Expr` over function arrows * ```scala - * Expr.betaReduceGiven(_): Expr[(given T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) + * Expr.betaReduceGiven(_): Expr[(T1, ..., Tn) ?=> R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) * ``` */ - def betaReduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, (given Args) => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { + def betaReduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(using tf: TupledFunction[F, Args ?=> R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { import qctx.tasty.{_, given} tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } /** Returns a null expresssion equivalent to `'{null}` */ - def nullExpr: (given QuoteContext) => Expr[Null] = (given qctx) => { + def nullExpr: QuoteContext ?=> Expr[Null] = qctx ?=> { import qctx.tasty.{_, given} Literal(Constant(null)).seal.asInstanceOf[Expr[Null]] } /** Returns a unit expresssion equivalent to `'{}` or `'{()}` */ - def unitExpr: (given QuoteContext) => Expr[Unit] = (given qctx) => { + def unitExpr: QuoteContext ?=> Expr[Unit] = qctx ?=> { import qctx.tasty.{_, given} Literal(Constant(())).seal.asInstanceOf[Expr[Unit]] } @@ -86,13 +86,13 @@ object Expr { * Given list of statements `s1 :: s2 :: ... :: Nil` and an expression `e` the resulting expression * will be equivalent to `'{ $s1; $s2; ...; $e }`. */ - def block[T](statements: List[Expr[_]], expr: Expr[T])(given qctx: QuoteContext): Expr[T] = { + def block[T](statements: List[Expr[_]], expr: Expr[T])(using qctx: QuoteContext): Expr[T] = { import qctx.tasty.{_, given} Block(statements.map(_.unseal), expr.unseal).seal.asInstanceOf[Expr[T]] } /** Lift a value into an expression containing the construction of that value */ - def apply[T: Liftable](x: T)(given QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) + def apply[T: Liftable](x: T)(using qctx: QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) /** Lifts this sequence of expressions into an expression of a sequence * @@ -106,7 +106,7 @@ object Expr { * '{ List(${Expr.ofSeq(List(1, 2, 3))}: _*) } // equvalent to '{ List(1, 2, 3) } * ``` */ - def ofSeq[T](xs: Seq[Expr[T]])(given tp: Type[T], qctx: QuoteContext): Expr[Seq[T]] = { + def ofSeq[T](xs: Seq[Expr[T]])(using tp: Type[T], qctx: QuoteContext): Expr[Seq[T]] = { import qctx.tasty.{_, given} Repeated(xs.map(_.unseal).toList, tp.unseal).seal.asInstanceOf[Expr[Seq[T]]] } @@ -119,7 +119,7 @@ object Expr { * to an expression equivalent to * `'{ List($e1, $e2, ...) }` typed as an `Expr[List[T]]` */ - def ofList[T](xs: Seq[Expr[T]])(given Type[T], QuoteContext): Expr[List[T]] = + def ofList[T](xs: Seq[Expr[T]])(using Type[T], QuoteContext): Expr[List[T]] = if (xs.isEmpty) '{ Nil } else '{ List(${ofSeq(xs)}: _*) } /** Lifts this sequence of expressions into an expression of a tuple @@ -129,7 +129,7 @@ object Expr { * to an expression equivalent to * `'{ ($e1, $e2, ...) }` typed as an `Expr[Tuple]` */ - def ofTuple(seq: Seq[Expr[_]])(given QuoteContext): Expr[Tuple] = { + def ofTuple(seq: Seq[Expr[_]])(using qctx: QuoteContext): Expr[Tuple] = { seq match { case Seq() => unitExpr @@ -183,7 +183,7 @@ object Expr { } /** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */ - def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T) (given qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = { + def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T)(using qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = { import qctx.tasty.{_, given} val elems: Seq[Expr[_]] = tup.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Expr[_]]] ofTuple(elems).cast[Tuple.InverseMap[T, Expr]] diff --git a/library/src/scala/quoted/Liftable.scala b/library/src/scala/quoted/Liftable.scala index 0cb32a593c0b..cdcacdbda1f7 100644 --- a/library/src/scala/quoted/Liftable.scala +++ b/library/src/scala/quoted/Liftable.scala @@ -8,7 +8,7 @@ import scala.reflect.ClassTag trait Liftable[T] { /** Lift a value into an expression containing the construction of that value */ - def toExpr(x: T): (given QuoteContext) => Expr[T] + def toExpr(x: T): QuoteContext ?=> Expr[T] } @@ -31,7 +31,7 @@ object Liftable { private class PrimitiveLiftable[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends Liftable[T] { /** Lift a primitive value `n` into `'{ n }` */ - def toExpr(x: T) = (given qctx) => { + def toExpr(x: T) = qctx ?=> { import qctx.tasty.{_, given} Literal(Constant(x)).seal.asInstanceOf[Expr[T]] } @@ -39,104 +39,104 @@ object Liftable { given ClassIsLiftable[T] : Liftable[Class[T]] = new Liftable[Class[T]] { /** Lift a `Class[T]` into `'{ classOf[T] }` */ - def toExpr(x: Class[T]) = (given qctx) => { + def toExpr(x: Class[T]) = qctx ?=> { import qctx.tasty.{_, given} Ref(defn.Predef_classOf).appliedToType(Type(x)).seal.asInstanceOf[Expr[Class[T]]] } } given ClassTagIsLiftable[T: Type] : Liftable[ClassTag[T]] = new Liftable[ClassTag[T]] { - def toExpr(ct: ClassTag[T]): (given QuoteContext) => Expr[ClassTag[T]] = + def toExpr(ct: ClassTag[T]): QuoteContext ?=> Expr[ClassTag[T]] = '{ ClassTag[T](${Expr(ct.runtimeClass.asInstanceOf[Class[T]])}) } } given ArrayIsLiftable[T: Type: Liftable: ClassTag] : Liftable[Array[T]] = new Liftable[Array[T]] { - def toExpr(arr: Array[T]): (given QuoteContext) => Expr[Array[T]] = + def toExpr(arr: Array[T]): QuoteContext ?=> Expr[Array[T]] = '{ Array[T](${Expr(arr.toSeq)}: _*)(${Expr(summon[ClassTag[T]])}) } } given ArrayOfBooleanIsLiftable : Liftable[Array[Boolean]] = new Liftable[Array[Boolean]] { - def toExpr(array: Array[Boolean]): (given QuoteContext) => Expr[Array[Boolean]] = + def toExpr(array: Array[Boolean]): QuoteContext ?=> Expr[Array[Boolean]] = if (array.length == 0) '{ Array.emptyBooleanArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfByteIsLiftable : Liftable[Array[Byte]] = new Liftable[Array[Byte]] { - def toExpr(array: Array[Byte]): (given QuoteContext) => Expr[Array[Byte]] = + def toExpr(array: Array[Byte]): QuoteContext ?=> Expr[Array[Byte]] = if (array.length == 0) '{ Array.emptyByteArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfShortIsLiftable : Liftable[Array[Short]] = new Liftable[Array[Short]] { - def toExpr(array: Array[Short]): (given QuoteContext) => Expr[Array[Short]] = + def toExpr(array: Array[Short]): QuoteContext ?=> Expr[Array[Short]] = if (array.length == 0) '{ Array.emptyShortArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfCharIsLiftable : Liftable[Array[Char]] = new Liftable[Array[Char]] { - def toExpr(array: Array[Char]): (given QuoteContext) => Expr[Array[Char]] = + def toExpr(array: Array[Char]): QuoteContext ?=> Expr[Array[Char]] = if (array.length == 0) '{ Array.emptyCharArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfIntIsLiftable : Liftable[Array[Int]] = new Liftable[Array[Int]] { - def toExpr(array: Array[Int]): (given QuoteContext) => Expr[Array[Int]] = + def toExpr(array: Array[Int]): QuoteContext ?=> Expr[Array[Int]] = if (array.length == 0) '{ Array.emptyIntArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfLongIsLiftable : Liftable[Array[Long]] = new Liftable[Array[Long]] { - def toExpr(array: Array[Long]): (given QuoteContext) => Expr[Array[Long]] = + def toExpr(array: Array[Long]): QuoteContext ?=> Expr[Array[Long]] = if (array.length == 0) '{ Array.emptyLongArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfFloatIsLiftable : Liftable[Array[Float]] = new Liftable[Array[Float]] { - def toExpr(array: Array[Float]): (given QuoteContext) => Expr[Array[Float]] = + def toExpr(array: Array[Float]): QuoteContext ?=> Expr[Array[Float]] = if (array.length == 0) '{ Array.emptyFloatArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfDoubleIsLiftable : Liftable[Array[Double]] = new Liftable[Array[Double]] { - def toExpr(array: Array[Double]): (given QuoteContext) => Expr[Array[Double]] = + def toExpr(array: Array[Double]): QuoteContext ?=> Expr[Array[Double]] = if (array.length == 0) '{ Array.emptyDoubleArray } else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } - given iArrayIsLiftable[T: Type](given ltArray: Liftable[Array[T]]): Liftable[IArray[T]] { - def toExpr(iarray: IArray[T]): (given QuoteContext) => Expr[IArray[T]] = + given iArrayIsLiftable[T: Type](using ltArray: Liftable[Array[T]]): Liftable[IArray[T]] { + def toExpr(iarray: IArray[T]): QuoteContext ?=> Expr[IArray[T]] = '{ ${ltArray.toExpr(iarray.asInstanceOf[Array[T]])}.asInstanceOf[IArray[T]] } } given [T: Type: Liftable] : Liftable[Seq[T]] = new Liftable[Seq[T]] { - def toExpr(xs: Seq[T]): (given QuoteContext) => Expr[Seq[T]] = + def toExpr(xs: Seq[T]): QuoteContext ?=> Expr[Seq[T]] = Expr.ofSeq(xs.map(summon[Liftable[T]].toExpr)) } given [T: Type: Liftable] : Liftable[List[T]] = new Liftable[List[T]] { - def toExpr(xs: List[T]): (given QuoteContext) => Expr[List[T]] = + def toExpr(xs: List[T]): QuoteContext ?=> Expr[List[T]] = Expr.ofList(xs.map(summon[Liftable[T]].toExpr)) } given [T: Type: Liftable] : Liftable[Set[T]] = new Liftable[Set[T]] { - def toExpr(set: Set[T]): (given QuoteContext) => Expr[Set[T]] = + def toExpr(set: Set[T]): QuoteContext ?=> Expr[Set[T]] = '{ Set(${Expr(set.toSeq)}: _*) } } given [T: Type: Liftable, U: Type: Liftable] : Liftable[Map[T, U]] = new Liftable[Map[T, U]] { - def toExpr(map: Map[T, U]): (given QuoteContext) => Expr[Map[T, U]] = + def toExpr(map: Map[T, U]): QuoteContext ?=> Expr[Map[T, U]] = '{ Map(${Expr(map.toSeq)}: _*) } } given [T: Type: Liftable] : Liftable[Option[T]] = new Liftable[Option[T]] { - def toExpr(x: Option[T]): (given QuoteContext) => Expr[Option[T]] = x match { + def toExpr(x: Option[T]): QuoteContext ?=> Expr[Option[T]] = x match { case Some(x) => '{ Some[T](${Expr(x)}) } case None => '{ None: Option[T] } } } given [L: Type: Liftable, R: Type: Liftable] : Liftable[Either[L, R]] = new Liftable[Either[L, R]] { - def toExpr(x: Either[L, R]): (given QuoteContext) => Expr[Either[L, R]] = x match { + def toExpr(x: Either[L, R]): QuoteContext ?=> Expr[Either[L, R]] = x match { case Left(x) => '{ Left[L, R](${Expr(x)}) } case Right(x) => '{ Right[L, R](${Expr(x)}) } } @@ -289,19 +289,19 @@ object Liftable { } given [H: Type: Liftable, T <: Tuple: Type: Liftable] : Liftable[H *: T] = new { - def toExpr(tup: H *: T): (given QuoteContext) => Expr[H *: T] = + def toExpr(tup: H *: T): QuoteContext ?=> Expr[H *: T] = '{ ${summon[Liftable[H]].toExpr(tup.head)} *: ${summon[Liftable[T]].toExpr(tup.tail)} } // '{ ${Expr(tup.head)} *: ${Expr(tup.tail)} } // TODO figure out why this fails during CI documentation } given Liftable[BigInt] = new Liftable[BigInt] { - def toExpr(x: BigInt): (given QuoteContext) => Expr[BigInt] = + def toExpr(x: BigInt): QuoteContext ?=> Expr[BigInt] = '{ BigInt(${Expr(x.toByteArray)}) } } /** Lift a BigDecimal using the default MathContext */ given Liftable[BigDecimal] = new Liftable[BigDecimal] { - def toExpr(x: BigDecimal): (given QuoteContext) => Expr[BigDecimal] = + def toExpr(x: BigDecimal): QuoteContext ?=> Expr[BigDecimal] = '{ BigDecimal(${Expr(x.toString)}) } } diff --git a/library/src/scala/quoted/Type.scala b/library/src/scala/quoted/Type.scala index 4d8c2b12b6eb..67292ea2b271 100644 --- a/library/src/scala/quoted/Type.scala +++ b/library/src/scala/quoted/Type.scala @@ -7,57 +7,57 @@ class Type[T <: AnyKind] private[scala] { type `$splice` = T /** Show a source code like representation of this type without syntax highlight */ - def show(given qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain) + def show(using qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain) /** Show a source code like representation of this type */ - def show(syntaxHighlight: SyntaxHighlight)(given qctx: QuoteContext): String = qctx.show(this, syntaxHighlight) + def show(syntaxHighlight: SyntaxHighlight)(using qctx: QuoteContext): String = qctx.show(this, syntaxHighlight) } /** Some basic type tags, currently incomplete */ object Type { - given UnitTag(given qctx: QuoteContext): Type[Unit] = { + given UnitTag(using qctx: QuoteContext): Type[Unit] = { import qctx.tasty.{_, given} defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]] } - given BooleanTag(given qctx: QuoteContext): Type[Boolean] = { + given BooleanTag(using qctx: QuoteContext): Type[Boolean] = { import qctx.tasty.{_, given} defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]] } - given ByteTag(given qctx: QuoteContext): Type[Byte] = { + given ByteTag(using qctx: QuoteContext): Type[Byte] = { import qctx.tasty.{_, given} defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]] } - given CharTag(given qctx: QuoteContext): Type[Char] = { + given CharTag(using qctx: QuoteContext): Type[Char] = { import qctx.tasty.{_, given} defn.CharType.seal.asInstanceOf[quoted.Type[Char]] } - given ShortTag(given qctx: QuoteContext): Type[Short] = { + given ShortTag(using qctx: QuoteContext): Type[Short] = { import qctx.tasty.{_, given} defn.ShortType.seal.asInstanceOf[quoted.Type[Short]] } - given IntTag(given qctx: QuoteContext): Type[Int] = { + given IntTag(using qctx: QuoteContext): Type[Int] = { import qctx.tasty.{_, given} defn.IntType.seal.asInstanceOf[quoted.Type[Int]] } - given LongTag(given qctx: QuoteContext): Type[Long] = { + given LongTag(using qctx: QuoteContext): Type[Long] = { import qctx.tasty.{_, given} defn.LongType.seal.asInstanceOf[quoted.Type[Long]] } - given FloatTag(given qctx: QuoteContext): Type[Float] = { + given FloatTag(using qctx: QuoteContext): Type[Float] = { import qctx.tasty.{_, given} defn.FloatType.seal.asInstanceOf[quoted.Type[Float]] } - given DoubleTag(given qctx: QuoteContext): Type[Double] = { + given DoubleTag(using qctx: QuoteContext): Type[Double] = { import qctx.tasty.{_, given} defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]] } diff --git a/library/src/scala/quoted/ValueOfExpr.scala b/library/src/scala/quoted/ValueOfExpr.scala index 0cef1d77b800..0a6348653cdb 100644 --- a/library/src/scala/quoted/ValueOfExpr.scala +++ b/library/src/scala/quoted/ValueOfExpr.scala @@ -10,7 +10,7 @@ trait ValueOfExpr[T] { * Returns `None` if the expression does not contain a value or contains side effects. * Otherwise returns the `Some` of the value. */ - def apply(x: Expr[T])(given QuoteContext): Option[T] + def apply(x: Expr[T])(using qctx: QuoteContext): Option[T] } @@ -29,11 +29,11 @@ object ValueOfExpr { private class PrimitiveValueOfExpr[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends ValueOfExpr[T] { /** Lift a quoted primitive value `'{ n }` into `n` */ - def apply(x: Expr[T])(given QuoteContext): Option[T] = matching.Const.unapply(x) + def apply(x: Expr[T])(using qctx: QuoteContext): Option[T] = matching.Const.unapply(x) } - given Option_delegate[T](given Type[T], ValueOfExpr[T]): ValueOfExpr[Option[T]] = new { - def apply(x: Expr[Option[T]])(given QuoteContext): Option[Option[T]] = x match { + given Option_delegate[T](using Type[T], ValueOfExpr[T]): ValueOfExpr[Option[T]] = new { + def apply(x: Expr[Option[T]])(using qctx: QuoteContext): Option[Option[T]] = x match { case '{ None: Option[T] } => Some(None) // FIXME: remove ascription, Matcher should be able to match this expression case '{ new Some[T](${Value(y)}) } => Some(Some(y)) case '{ Some[T](${Value(y)}) } => Some(Some(y)) @@ -43,7 +43,7 @@ object ValueOfExpr { } given StringContext_delegate: ValueOfExpr[StringContext] = new { - def apply(x: Expr[StringContext])(given QuoteContext): Option[StringContext] = x match { + def apply(x: Expr[StringContext])(using qctx: QuoteContext): Option[StringContext] = x match { case '{ new StringContext(${ConstSeq(args)}: _*) } => Some(StringContext(args: _*)) case '{ StringContext(${ConstSeq(args)}: _*) } => Some(StringContext(args: _*)) case _ => None @@ -52,8 +52,8 @@ object ValueOfExpr { } - given Tuple1_delegate[T1](given Type[T1], ValueOfExpr[T1]): ValueOfExpr[Tuple1[T1]] = new { - def apply(x: Expr[Tuple1[T1]])(given QuoteContext): Option[Tuple1[T1]] = x match { + given Tuple1_delegate[T1](using Type[T1], ValueOfExpr[T1]): ValueOfExpr[Tuple1[T1]] = new { + def apply(x: Expr[Tuple1[T1]])(using qctx: QuoteContext): Option[Tuple1[T1]] = x match { case '{ new Tuple1[T1](${Value(y)}) } => Some(Tuple1(y)) case '{ Tuple1[T1](${Value(y)}) } => Some(Tuple1(y)) case _ => None @@ -61,8 +61,8 @@ object ValueOfExpr { override def toString(): String = "scala.quoted.ValueOfExpr.Tuple1_delegate" } - given Tuple2_delegate[T1, T2](given Type[T1], Type[T2], ValueOfExpr[T1], ValueOfExpr[T2]): ValueOfExpr[Tuple2[T1, T2]] = new { - def apply(x: Expr[Tuple2[T1, T2]])(given QuoteContext): Option[Tuple2[T1, T2]] = x match { + given Tuple2_delegate[T1, T2](using Type[T1], Type[T2], ValueOfExpr[T1], ValueOfExpr[T2]): ValueOfExpr[Tuple2[T1, T2]] = new { + def apply(x: Expr[Tuple2[T1, T2]])(using qctx: QuoteContext): Option[Tuple2[T1, T2]] = x match { case '{ new Tuple2[T1, T2](${Value(y1)}, ${Value(y2)}) } => Some(Tuple2(y1, y2)) case '{ Tuple2[T1, T2](${Value(y1)}, ${Value(y2)}) } => Some(Tuple2(y1, y2)) case _ => None @@ -71,8 +71,8 @@ object ValueOfExpr { } - given Tuple3_delegate[T1, T2, T3](given Type[T1], Type[T2], Type[T3], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3]): ValueOfExpr[Tuple3[T1, T2, T3]] = new { - def apply(x: Expr[Tuple3[T1, T2, T3]])(given QuoteContext): Option[Tuple3[T1, T2, T3]] = x match { + given Tuple3_delegate[T1, T2, T3](using Type[T1], Type[T2], Type[T3], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3]): ValueOfExpr[Tuple3[T1, T2, T3]] = new { + def apply(x: Expr[Tuple3[T1, T2, T3]])(using qctx: QuoteContext): Option[Tuple3[T1, T2, T3]] = x match { case '{ new Tuple3[T1, T2, T3](${Value(y1)}, ${Value(y2)}, ${Value(y3)}) } => Some(Tuple3(y1, y2, y3)) case '{ Tuple3[T1, T2, T3](${Value(y1)}, ${Value(y2)}, ${Value(y3)}) } => Some(Tuple3(y1, y2, y3)) case _ => None @@ -81,8 +81,8 @@ object ValueOfExpr { } - given Tuple4_delegate[T1, T2, T3, T4](given Type[T1], Type[T2], Type[T3], Type[T4], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4]): ValueOfExpr[Tuple4[T1, T2, T3, T4]] = new { - def apply(x: Expr[Tuple4[T1, T2, T3, T4]])(given QuoteContext): Option[Tuple4[T1, T2, T3, T4]] = x match { + given Tuple4_delegate[T1, T2, T3, T4](using Type[T1], Type[T2], Type[T3], Type[T4], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4]): ValueOfExpr[Tuple4[T1, T2, T3, T4]] = new { + def apply(x: Expr[Tuple4[T1, T2, T3, T4]])(using qctx: QuoteContext): Option[Tuple4[T1, T2, T3, T4]] = x match { case '{ new Tuple4[T1, T2, T3, T4](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}) } => Some(Tuple4(y1, y2, y3, y4)) case '{ Tuple4[T1, T2, T3, T4](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}) } => Some(Tuple4(y1, y2, y3, y4)) case _ => None @@ -91,8 +91,8 @@ object ValueOfExpr { } - given Tuple5_delegate[T1, T2, T3, T4, T5](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5]): ValueOfExpr[Tuple5[T1, T2, T3, T4, T5]] = new { - def apply(x: Expr[Tuple5[T1, T2, T3, T4, T5]])(given QuoteContext): Option[Tuple5[T1, T2, T3, T4, T5]] = x match { + given Tuple5_delegate[T1, T2, T3, T4, T5](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5]): ValueOfExpr[Tuple5[T1, T2, T3, T4, T5]] = new { + def apply(x: Expr[Tuple5[T1, T2, T3, T4, T5]])(using qctx: QuoteContext): Option[Tuple5[T1, T2, T3, T4, T5]] = x match { case '{ new Tuple5[T1, T2, T3, T4, T5](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}) } => Some(Tuple5(y1, y2, y3, y4, y5)) case '{ Tuple5[T1, T2, T3, T4, T5](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}) } => Some(Tuple5(y1, y2, y3, y4, y5)) case _ => None @@ -101,8 +101,8 @@ object ValueOfExpr { } - given Tuple6_delegate[T1, T2, T3, T4, T5, T6](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6]): ValueOfExpr[Tuple6[T1, T2, T3, T4, T5, T6]] = new { - def apply(x: Expr[Tuple6[T1, T2, T3, T4, T5, T6]])(given QuoteContext): Option[Tuple6[T1, T2, T3, T4, T5, T6]] = x match { + given Tuple6_delegate[T1, T2, T3, T4, T5, T6](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6]): ValueOfExpr[Tuple6[T1, T2, T3, T4, T5, T6]] = new { + def apply(x: Expr[Tuple6[T1, T2, T3, T4, T5, T6]])(using qctx: QuoteContext): Option[Tuple6[T1, T2, T3, T4, T5, T6]] = x match { case '{ new Tuple6[T1, T2, T3, T4, T5, T6](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}) } => Some(Tuple6(y1, y2, y3, y4, y5, y6)) case '{ Tuple6[T1, T2, T3, T4, T5, T6](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}) } => Some(Tuple6(y1, y2, y3, y4, y5, y6)) case _ => None @@ -111,8 +111,8 @@ object ValueOfExpr { } - given Tuple7_delegate[T1, T2, T3, T4, T5, T6, T7](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7]): ValueOfExpr[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = new { - def apply(x: Expr[Tuple7[T1, T2, T3, T4, T5, T6, T7]])(given QuoteContext): Option[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = x match { + given Tuple7_delegate[T1, T2, T3, T4, T5, T6, T7](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7]): ValueOfExpr[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = new { + def apply(x: Expr[Tuple7[T1, T2, T3, T4, T5, T6, T7]])(using qctx: QuoteContext): Option[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = x match { case '{ new Tuple7[T1, T2, T3, T4, T5, T6, T7](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}) } => Some(Tuple7(y1, y2, y3, y4, y5, y6, y7)) case '{ Tuple7[T1, T2, T3, T4, T5, T6, T7](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}) } => Some(Tuple7(y1, y2, y3, y4, y5, y6, y7)) case _ => None @@ -121,8 +121,8 @@ object ValueOfExpr { } - given Tuple8_delegate[T1, T2, T3, T4, T5, T6, T7, T8](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8]): ValueOfExpr[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = new { - def apply(x: Expr[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]])(given QuoteContext): Option[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = x match { + given Tuple8_delegate[T1, T2, T3, T4, T5, T6, T7, T8](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8]): ValueOfExpr[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = new { + def apply(x: Expr[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]])(using qctx: QuoteContext): Option[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = x match { case '{ new Tuple8[T1, T2, T3, T4, T5, T6, T7, T8](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}) } => Some(Tuple8(y1, y2, y3, y4, y5, y6, y7, y8)) case '{ Tuple8[T1, T2, T3, T4, T5, T6, T7, T8](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}) } => Some(Tuple8(y1, y2, y3, y4, y5, y6, y7, y8)) case _ => None @@ -131,8 +131,8 @@ object ValueOfExpr { } - given Tuple9_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9]): ValueOfExpr[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = new { - def apply(x: Expr[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]])(given QuoteContext): Option[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = x match { + given Tuple9_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9]): ValueOfExpr[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = new { + def apply(x: Expr[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]])(using qctx: QuoteContext): Option[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = x match { case '{ new Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}) } => Some(Tuple9(y1, y2, y3, y4, y5, y6, y7, y8, y9)) case '{ Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}) } => Some(Tuple9(y1, y2, y3, y4, y5, y6, y7, y8, y9)) case _ => None @@ -141,8 +141,8 @@ object ValueOfExpr { } - given Tuple10_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10]): ValueOfExpr[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = new { - def apply(x: Expr[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]])(given QuoteContext): Option[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = x match { + given Tuple10_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10]): ValueOfExpr[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = new { + def apply(x: Expr[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]])(using qctx: QuoteContext): Option[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = x match { case '{ new Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}) } => Some(Tuple10(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10)) case '{ Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}) } => Some(Tuple10(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10)) case _ => None @@ -151,8 +151,8 @@ object ValueOfExpr { } - given Tuple11_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11]): ValueOfExpr[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = new { - def apply(x: Expr[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]])(given QuoteContext): Option[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = x match { + given Tuple11_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11]): ValueOfExpr[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = new { + def apply(x: Expr[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]])(using qctx: QuoteContext): Option[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = x match { case '{ new Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}) } => Some(Tuple11(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11)) case '{ Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}) } => Some(Tuple11(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11)) case _ => None @@ -161,8 +161,8 @@ object ValueOfExpr { } - given Tuple12_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12]): ValueOfExpr[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = new { - def apply(x: Expr[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]])(given QuoteContext): Option[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = x match { + given Tuple12_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12]): ValueOfExpr[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = new { + def apply(x: Expr[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]])(using qctx: QuoteContext): Option[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = x match { case '{ new Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}) } => Some(Tuple12(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12)) case '{ Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}) } => Some(Tuple12(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12)) case _ => None @@ -171,8 +171,8 @@ object ValueOfExpr { } - given Tuple13_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13]): ValueOfExpr[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = new { - def apply(x: Expr[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]])(given QuoteContext): Option[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = x match { + given Tuple13_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13]): ValueOfExpr[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = new { + def apply(x: Expr[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]])(using qctx: QuoteContext): Option[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = x match { case '{ new Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}) } => Some(Tuple13(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13)) case '{ Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}) } => Some(Tuple13(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13)) case _ => None @@ -181,8 +181,8 @@ object ValueOfExpr { } - given Tuple14_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14]): ValueOfExpr[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = new { - def apply(x: Expr[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]])(given QuoteContext): Option[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = x match { + given Tuple14_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14]): ValueOfExpr[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = new { + def apply(x: Expr[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]])(using qctx: QuoteContext): Option[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = x match { case '{ new Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}) } => Some(Tuple14(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14)) case '{ Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}) } => Some(Tuple14(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14)) case _ => None @@ -191,8 +191,8 @@ object ValueOfExpr { } - given Tuple15_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15]): ValueOfExpr[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = new { - def apply(x: Expr[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]])(given QuoteContext): Option[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = x match { + given Tuple15_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15]): ValueOfExpr[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = new { + def apply(x: Expr[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]])(using qctx: QuoteContext): Option[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = x match { case '{ new Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}) } => Some(Tuple15(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15)) case '{ Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}) } => Some(Tuple15(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15)) case _ => None @@ -201,8 +201,8 @@ object ValueOfExpr { } - given Tuple16_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16]): ValueOfExpr[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = new { - def apply(x: Expr[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]])(given QuoteContext): Option[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = x match { + given Tuple16_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16]): ValueOfExpr[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = new { + def apply(x: Expr[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]])(using qctx: QuoteContext): Option[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = x match { case '{ new Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}) } => Some(Tuple16(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16)) case '{ Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}) } => Some(Tuple16(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16)) case _ => None @@ -211,8 +211,8 @@ object ValueOfExpr { } - given Tuple17_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17]): ValueOfExpr[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = new { - def apply(x: Expr[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]])(given QuoteContext): Option[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = x match { + given Tuple17_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17]): ValueOfExpr[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = new { + def apply(x: Expr[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]])(using qctx: QuoteContext): Option[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = x match { case '{ new Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}) } => Some(Tuple17(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17)) case '{ Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}) } => Some(Tuple17(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17)) case _ => None @@ -221,8 +221,8 @@ object ValueOfExpr { } - given Tuple18_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18]): ValueOfExpr[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = new { - def apply(x: Expr[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]])(given QuoteContext): Option[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = x match { + given Tuple18_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18]): ValueOfExpr[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = new { + def apply(x: Expr[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]])(using qctx: QuoteContext): Option[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = x match { case '{ new Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}) } => Some(Tuple18(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18)) case '{ Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}) } => Some(Tuple18(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18)) case _ => None @@ -231,8 +231,8 @@ object ValueOfExpr { } - given Tuple19_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19]): ValueOfExpr[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = new { - def apply(x: Expr[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]])(given QuoteContext): Option[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = x match { + given Tuple19_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19]): ValueOfExpr[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = new { + def apply(x: Expr[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]])(using qctx: QuoteContext): Option[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = x match { case '{ new Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}) } => Some(Tuple19(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19)) case '{ Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}) } => Some(Tuple19(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19)) case _ => None @@ -241,8 +241,8 @@ object ValueOfExpr { } - given Tuple20_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], Type[T20], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19], ValueOfExpr[T20]): ValueOfExpr[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = new { - def apply(x: Expr[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]])(given QuoteContext): Option[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = x match { + given Tuple20_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], Type[T20], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19], ValueOfExpr[T20]): ValueOfExpr[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = new { + def apply(x: Expr[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]])(using qctx: QuoteContext): Option[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = x match { case '{ new Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}, ${Value(y20)}) } => Some(Tuple20(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19, y20)) case '{ Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}, ${Value(y20)}) } => Some(Tuple20(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19, y20)) case _ => None @@ -251,8 +251,8 @@ object ValueOfExpr { } - given Tuple21_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], Type[T20], Type[T21], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19], ValueOfExpr[T20], ValueOfExpr[T21]): ValueOfExpr[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = new { - def apply(x: Expr[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]])(given QuoteContext): Option[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = x match { + given Tuple21_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], Type[T20], Type[T21], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19], ValueOfExpr[T20], ValueOfExpr[T21]): ValueOfExpr[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = new { + def apply(x: Expr[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]])(using qctx: QuoteContext): Option[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = x match { case '{ new Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}, ${Value(y20)}, ${Value(y21)}) } => Some(Tuple21(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19, y20, y21)) case '{ Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}, ${Value(y20)}, ${Value(y21)}) } => Some(Tuple21(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19, y20, y21)) case _ => None @@ -261,8 +261,8 @@ object ValueOfExpr { } - given Tuple22_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22](given Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], Type[T20], Type[T21], Type[T22], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19], ValueOfExpr[T20], ValueOfExpr[T21], ValueOfExpr[T22]): ValueOfExpr[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = new { - def apply(x: Expr[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]])(given QuoteContext): Option[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = x match { + given Tuple22_delegate[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22](using Type[T1], Type[T2], Type[T3], Type[T4], Type[T5], Type[T6], Type[T7], Type[T8], Type[T9], Type[T10], Type[T11], Type[T12], Type[T13], Type[T14], Type[T15], Type[T16], Type[T17], Type[T18], Type[T19], Type[T20], Type[T21], Type[T22], ValueOfExpr[T1], ValueOfExpr[T2], ValueOfExpr[T3], ValueOfExpr[T4], ValueOfExpr[T5], ValueOfExpr[T6], ValueOfExpr[T7], ValueOfExpr[T8], ValueOfExpr[T9], ValueOfExpr[T10], ValueOfExpr[T11], ValueOfExpr[T12], ValueOfExpr[T13], ValueOfExpr[T14], ValueOfExpr[T15], ValueOfExpr[T16], ValueOfExpr[T17], ValueOfExpr[T18], ValueOfExpr[T19], ValueOfExpr[T20], ValueOfExpr[T21], ValueOfExpr[T22]): ValueOfExpr[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = new { + def apply(x: Expr[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]])(using qctx: QuoteContext): Option[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = x match { case '{ new Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}, ${Value(y20)}, ${Value(y21)}, ${Value(y22)}) } => Some(Tuple22(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19, y20, y21, y22)) case '{ Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22](${Value(y1)}, ${Value(y2)}, ${Value(y3)}, ${Value(y4)}, ${Value(y5)}, ${Value(y6)}, ${Value(y7)}, ${Value(y8)}, ${Value(y9)}, ${Value(y10)}, ${Value(y11)}, ${Value(y12)}, ${Value(y13)}, ${Value(y14)}, ${Value(y15)}, ${Value(y16)}, ${Value(y17)}, ${Value(y18)}, ${Value(y19)}, ${Value(y20)}, ${Value(y21)}, ${Value(y22)}) } => Some(Tuple22(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19, y20, y21, y22)) case _ => None @@ -270,8 +270,8 @@ object ValueOfExpr { override def toString(): String = "scala.quoted.ValueOfExpr.Tuple22_delegate" } - given Seq_delegate[T](given Type[T], ValueOfExpr[T]): ValueOfExpr[Seq[T]] = new { - def apply(x: Expr[Seq[T]])(given QuoteContext): Option[Seq[T]] = x match { + given Seq_delegate[T](using Type[T], ValueOfExpr[T]): ValueOfExpr[Seq[T]] = new { + def apply(x: Expr[Seq[T]])(using qctx: QuoteContext): Option[Seq[T]] = x match { case ValueSeq(elems) => Some(elems) case '{ scala.collection.Seq[T](${ValueSeq(elems)}: _*) } => Some(elems) case '{ scala.collection.immutable.Seq[T](${ValueSeq(elems)}: _*) } => Some(elems) diff --git a/library/src/scala/quoted/autolift.scala b/library/src/scala/quoted/autolift.scala index 7d95cbcb6a87..627986b6f697 100644 --- a/library/src/scala/quoted/autolift.scala +++ b/library/src/scala/quoted/autolift.scala @@ -3,5 +3,5 @@ package scala.quoted /** Enable implicit conversion from a term of type `T` to an expression of type `Expr[T]` */ object autolift { /** Implicit conversion from a term of type `T` to an expression of type `Expr[T]` */ - given autoToExpr[T](given Liftable[T], QuoteContext): Conversion[T, Expr[T]] = Expr(_) + given autoToExpr[T](using Liftable[T], QuoteContext): Conversion[T, Expr[T]] = Expr(_) } diff --git a/library/src/scala/quoted/matching/Const.scala b/library/src/scala/quoted/matching/Const.scala index 3d3e61bf5ef7..d2cc1b378adb 100644 --- a/library/src/scala/quoted/matching/Const.scala +++ b/library/src/scala/quoted/matching/Const.scala @@ -14,7 +14,7 @@ package matching */ object Const { - def unapply[T](expr: Expr[T])(given qctx: QuoteContext): Option[T] = { + def unapply[T](expr: Expr[T])(using qctx: QuoteContext): Option[T] = { import qctx.tasty.{_, given} def rec(tree: Term): Option[T] = tree match { case Literal(c) => Some(c.value.asInstanceOf[T]) diff --git a/library/src/scala/quoted/matching/ConstSeq.scala b/library/src/scala/quoted/matching/ConstSeq.scala index 1d4a7769790f..b76fa1458c7b 100644 --- a/library/src/scala/quoted/matching/ConstSeq.scala +++ b/library/src/scala/quoted/matching/ConstSeq.scala @@ -9,14 +9,14 @@ object ConstSeq { * Usage: * ```scala * inline def sum(args: Int*): Int = ${ sumExpr('args) } - * def sumExpr(argsExpr: Expr[Seq[Int]])(given QuoteContext): Expr[Int] = argsExpr match + * def sumExpr(argsExpr: Expr[Seq[Int]])(usingusing QuoteContext): Expr[Int] = argsExpr match * case ConstSeq(args) => * // args: Seq[Int] * ... * } * ``` */ - def unapply[T](expr: Expr[Seq[T]])(given qctx: QuoteContext): Option[Seq[T]] = expr match { + def unapply[T](expr: Expr[Seq[T]])(using qctx: QuoteContext): Option[Seq[T]] = expr match { case ExprSeq(elems) => elems.foldRight(Option(List.empty[T])) { (elem, acc) => (elem, acc) match { diff --git a/library/src/scala/quoted/matching/ExprSeq.scala b/library/src/scala/quoted/matching/ExprSeq.scala index 717b5b9471de..fc4933e4a0a4 100644 --- a/library/src/scala/quoted/matching/ExprSeq.scala +++ b/library/src/scala/quoted/matching/ExprSeq.scala @@ -9,14 +9,14 @@ object ExprSeq { * Usage: * ```scala * inline def sum(args: Int*): Int = ${ sumExpr('args) } - * def sumExpr(argsExpr: Expr[Seq[Int]])(given QuoteContext): Expr[Int] = argsExpr match + * def sumExpr(argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[Int] = argsExpr match * case ExprSeq(argExprs) => * // argExprs: Seq[Expr[Int]] * ... * } * ``` */ - def unapply[T](expr: Expr[Seq[T]])(given qctx: QuoteContext): Option[Seq[Expr[T]]] = { + def unapply[T](expr: Expr[Seq[T]])(using qctx: QuoteContext): Option[Seq[Expr[T]]] = { import qctx.tasty.{_, given} def rec(tree: Term): Option[Seq[Expr[T]]] = tree match { case Typed(Repeated(elems, _), _) => Some(elems.map(x => x.seal.asInstanceOf[Expr[T]])) diff --git a/library/src/scala/quoted/matching/Value.scala b/library/src/scala/quoted/matching/Value.scala index 13b394614cf6..38472336f03e 100644 --- a/library/src/scala/quoted/matching/Value.scala +++ b/library/src/scala/quoted/matching/Value.scala @@ -13,7 +13,7 @@ object Value { * } * ``` */ - def unapply[T](expr: Expr[T])(given valueOf: ValueOfExpr[T], qxtc: QuoteContext): Option[T] = + def unapply[T](expr: Expr[T])(using valueOf: ValueOfExpr[T], qxtc: QuoteContext): Option[T] = valueOf(expr) } diff --git a/library/src/scala/quoted/matching/ValueSeq.scala b/library/src/scala/quoted/matching/ValueSeq.scala index 1a31ba1845bc..87d99dcd4242 100644 --- a/library/src/scala/quoted/matching/ValueSeq.scala +++ b/library/src/scala/quoted/matching/ValueSeq.scala @@ -9,14 +9,14 @@ object ValueSeq { * Usage: * ```scala * inline def sum(args: Int*): Int = ${ sumExpr('args) } - * def sumExpr(argsExpr: Expr[Seq[Int]])(given QuoteContext): Expr[Int] = argsExpr match + * def sumExpr(argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[Int] = argsExpr match * case ValueSeq(args) => * // args: Seq[Int] * ... * } * ``` */ - def unapply[T](expr: Expr[Seq[T]])(given valueOf: ValueOfExpr[T], qctx: QuoteContext): Option[Seq[T]] = expr match { + def unapply[T](expr: Expr[Seq[T]])(using valueOf: ValueOfExpr[T], qctx: QuoteContext): Option[Seq[T]] = expr match { case ExprSeq(elems) => elems.foldRight(Option(List.empty[T])) { (elem, acc) => (elem, acc) match { diff --git a/library/src/scala/quoted/matching/package.scala b/library/src/scala/quoted/matching/package.scala index 8267d5c2a465..49165d0d6bfb 100644 --- a/library/src/scala/quoted/matching/package.scala +++ b/library/src/scala/quoted/matching/package.scala @@ -10,7 +10,7 @@ package object matching { * @param tpe quoted type of the implicit parameter * @param qctx current context */ - def summonExpr[T](given tpe: Type[T])(given qctx: QuoteContext): Option[Expr[T]] = { + def summonExpr[T](given tpe: Type[T])(using qctx: QuoteContext): Option[Expr[T]] = { import qctx.tasty.{_, given} searchImplicit(tpe.unseal.tpe) match { case iss: ImplicitSearchSuccess => Some(iss.tree.seal.asInstanceOf[Expr[T]]) diff --git a/library/src/scala/quoted/util/ExprMap.scala b/library/src/scala/quoted/util/ExprMap.scala index bbd37f11ea5f..5f1704a18597 100644 --- a/library/src/scala/quoted/util/ExprMap.scala +++ b/library/src/scala/quoted/util/ExprMap.scala @@ -5,14 +5,14 @@ import scala.quoted._ trait ExprMap { /** Map an expression `e` with a type `tpe` */ - def transform[T](e: Expr[T])(given qctx: QuoteContext, tpe: Type[T]): Expr[T] + def transform[T](e: Expr[T])(using qctx: QuoteContext, tpe: Type[T]): Expr[T] /** Map subexpressions an expression `e` with a type `tpe` */ - def transformChildren[T](e: Expr[T])(given qctx: QuoteContext, tpe: Type[T]): Expr[T] = { + def transformChildren[T](e: Expr[T])(using qctx: QuoteContext, tpe: Type[T]): Expr[T] = { import qctx.tasty.{_, given} final class MapChildren() { - def transformStatement(tree: Statement)(given ctx: Context): Statement = { + def transformStatement(tree: Statement)(using ctx: Context): Statement = { def localCtx(definition: Definition): Context = definition.symbol.localContext tree match { case tree: Term => @@ -24,7 +24,7 @@ trait ExprMap { } } - def transformDefinition(tree: Definition)(given ctx: Context): Definition = { + def transformDefinition(tree: Definition)(using ctx: Context): Definition = { def localCtx(definition: Definition): Context = definition.symbol.localContext tree match { case tree: ValDef => @@ -42,7 +42,7 @@ trait ExprMap { } } - def transformTermChildren(tree: Term, tpe: Type)(given ctx: Context): Term = tree match { + def transformTermChildren(tree: Term, tpe: Type)(using ctx: Context): Term = tree match { case Ident(name) => tree case Select(qualifier, name) => @@ -99,7 +99,7 @@ trait ExprMap { Inlined.copy(tree)(call, transformDefinitions(bindings), transformTerm(expansion, tpe)/*()call.symbol.localContext)*/) } - def transformTerm(tree: Term, tpe: Type)(given ctx: Context): Term = + def transformTerm(tree: Term, tpe: Type)(using ctx: Context): Term = tree match { case _: Closure => tree @@ -117,22 +117,22 @@ trait ExprMap { } } - def transformTypeTree(tree: TypeTree)(given ctx: Context): TypeTree = tree + def transformTypeTree(tree: TypeTree)(using ctx: Context): TypeTree = tree - def transformCaseDef(tree: CaseDef, tpe: Type)(given ctx: Context): CaseDef = + def transformCaseDef(tree: CaseDef, tpe: Type)(using ctx: Context): CaseDef = CaseDef.copy(tree)(tree.pattern, tree.guard.map(x => transformTerm(x, defn.BooleanType)), transformTerm(tree.rhs, tpe)) - def transformTypeCaseDef(tree: TypeCaseDef)(given ctx: Context): TypeCaseDef = { + def transformTypeCaseDef(tree: TypeCaseDef)(using ctx: Context): TypeCaseDef = { TypeCaseDef.copy(tree)(transformTypeTree(tree.pattern), transformTypeTree(tree.rhs)) } - def transformStats(trees: List[Statement])(given ctx: Context): List[Statement] = + def transformStats(trees: List[Statement])(using ctx: Context): List[Statement] = trees mapConserve (transformStatement(_)) - def transformDefinitions(trees: List[Definition])(given ctx: Context): List[Definition] = + def transformDefinitions(trees: List[Definition])(using ctx: Context): List[Definition] = trees mapConserve (transformDefinition(_)) - def transformTerms(trees: List[Term], tpes: List[Type])(given ctx: Context): List[Term] = + def transformTerms(trees: List[Term], tpes: List[Type])(using ctx: Context): List[Term] = var tpes2 = tpes // TODO use proper zipConserve trees mapConserve { x => val tpe :: tail = tpes2 @@ -140,16 +140,16 @@ trait ExprMap { transformTerm(x, tpe) } - def transformTerms(trees: List[Term], tpe: Type)(given ctx: Context): List[Term] = + def transformTerms(trees: List[Term], tpe: Type)(using ctx: Context): List[Term] = trees.mapConserve(x => transformTerm(x, tpe)) - def transformTypeTrees(trees: List[TypeTree])(given ctx: Context): List[TypeTree] = + def transformTypeTrees(trees: List[TypeTree])(using ctx: Context): List[TypeTree] = trees mapConserve (transformTypeTree(_)) - def transformCaseDefs(trees: List[CaseDef], tpe: Type)(given ctx: Context): List[CaseDef] = + def transformCaseDefs(trees: List[CaseDef], tpe: Type)(using ctx: Context): List[CaseDef] = trees mapConserve (x => transformCaseDef(x, tpe)) - def transformTypeCaseDefs(trees: List[TypeCaseDef])(given ctx: Context): List[TypeCaseDef] = + def transformTypeCaseDefs(trees: List[TypeCaseDef])(using ctx: Context): List[TypeCaseDef] = trees mapConserve (transformTypeCaseDef(_)) } diff --git a/library/src/scala/quoted/util/Var.scala b/library/src/scala/quoted/util/Var.scala index fec5d138e223..670f7ee9183a 100644 --- a/library/src/scala/quoted/util/Var.scala +++ b/library/src/scala/quoted/util/Var.scala @@ -7,10 +7,10 @@ package util sealed trait Var[T] { // Retrieves the value of the variable - def get(given QuoteContext): Expr[T] + def get(using qctx: QuoteContext): Expr[T] // Update the variable with the expression of a value (`e` corresponds to the RHS of variable assignment `x = e`) - def update(e: Expr[T])(given QuoteContext): Expr[Unit] + def update(e: Expr[T])(given qctx: QuoteContext): Expr[Unit] } object Var { @@ -34,13 +34,13 @@ object Var { * x * } */ - def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U])(given QuoteContext): Expr[U] = '{ + def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U])(given qctx: QuoteContext): Expr[U] = '{ var x = $init ${ body( new Var[T] { - def get(given QuoteContext): Expr[T] = 'x - def update(e: Expr[T])(given QuoteContext): Expr[Unit] = '{ x = $e } + def get(using qctx: QuoteContext): Expr[T] = 'x + def update(e: Expr[T])(using qctx: QuoteContext): Expr[Unit] = '{ x = $e } } ) } From 091b8f34c4f862cf1a0d32870e288adde99c46cb Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 5 Feb 2020 15:45:42 +0100 Subject: [PATCH 2/4] Update given syntax --- .../scala/internal/quoted/CompileTime.scala | 4 +-- library/src/scala/internal/quoted/Expr.scala | 2 +- .../src/scala/internal/quoted/Matcher.scala | 26 +++++++++---------- library/src/scala/internal/quoted/Type.scala | 2 +- .../src/scala/internal/quoted/Unpickler.scala | 6 ++--- .../quote-matcher-runtime/quoted_1.scala | 2 +- .../quote-type-matcher/quoted_1.scala | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/library/src/scala/internal/quoted/CompileTime.scala b/library/src/scala/internal/quoted/CompileTime.scala index c135137b37a2..2ecba1d6a9ba 100644 --- a/library/src/scala/internal/quoted/CompileTime.scala +++ b/library/src/scala/internal/quoted/CompileTime.scala @@ -8,11 +8,11 @@ object CompileTime { /** A term quote is desugared by the compiler into a call to this method */ @compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.exprQuote`") - def exprQuote[T](x: T): (given QuoteContext) => Expr[T] = ??? + def exprQuote[T](x: T): QuoteContext ?=> Expr[T] = ??? /** A term splice is desugared by the compiler into a call to this method */ @compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.exprSplice`") - def exprSplice[T](x: (given QuoteContext) => Expr[T]): T = ??? + def exprSplice[T](x: QuoteContext ?=> Expr[T]): T = ??? /** A type quote is desugared by the compiler into a call to this method */ @compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.typeQuote`") diff --git a/library/src/scala/internal/quoted/Expr.scala b/library/src/scala/internal/quoted/Expr.scala index b586792fe9d8..370f34e44e62 100644 --- a/library/src/scala/internal/quoted/Expr.scala +++ b/library/src/scala/internal/quoted/Expr.scala @@ -32,7 +32,7 @@ object Expr { * @param qctx the current QuoteContext * @return None if it did not match, `Some(tup)` if it matched where `tup` contains `Expr[Ti]`` */ - def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: scala.quoted.Expr[_])(implicit patternExpr: scala.quoted.Expr[_], + def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: scala.quoted.Expr[_])(using patternExpr: scala.quoted.Expr[_], hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = { import qctx.tasty.{_, given} new Matcher.QuoteMatcher[qctx.type].termMatch(scrutineeExpr.unseal, patternExpr.unseal, hasTypeSplices).asInstanceOf[Option[Tup]] diff --git a/library/src/scala/internal/quoted/Matcher.scala b/library/src/scala/internal/quoted/Matcher.scala index 21f351a51e71..69c6e73998a6 100644 --- a/library/src/scala/internal/quoted/Matcher.scala +++ b/library/src/scala/internal/quoted/Matcher.scala @@ -7,7 +7,7 @@ import scala.quoted.matching.Sym private[quoted] object Matcher { - class QuoteMatcher[QCtx <: QuoteContext & Singleton](given val qctx: QCtx) { + class QuoteMatcher[QCtx <: QuoteContext & Singleton](using val qctx: QCtx) { // TODO improve performance // TODO use flag from qctx.tasty.rootContext. Maybe -debug or add -debug-macros @@ -25,7 +25,7 @@ private[quoted] object Matcher { */ private type Env = Map[Symbol, Symbol] - inline private def withEnv[T](env: Env)(body: => (given Env) => T): T = body(given env) + inline private def withEnv[T](env: Env)(body: => Env ?=> T): T = body(given env) class SymBinding(val sym: Symbol, val fromAbove: Boolean) @@ -98,7 +98,7 @@ private[quoted] object Matcher { private given treeListOps: extension (scrutinees: List[Tree]) { /** Check that all trees match with =?= and concatenate the results with && */ - def =?= (patterns: List[Tree])(given Context, Env): Matching = + def =?= (patterns: List[Tree])(using Context, Env): Matching = matchLists(scrutinees, patterns)(_ =?= _) } @@ -112,7 +112,7 @@ private[quoted] object Matcher { * @param `summon[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`. * @return `None` if it did not match or `Some(tup: Tuple)` if it matched where `tup` contains the contents of the holes. */ - def =?= (pattern0: Tree)(given Context, Env): Matching = { + def =?= (pattern0: Tree)(using Context, Env): Matching = { /** Normalize the tree */ def normalize(tree: Tree): Tree = tree match { @@ -157,7 +157,7 @@ private[quoted] object Matcher { def bodyFn(lambdaArgs: List[Tree]): Tree = { val argsMap = args.map(_.symbol).zip(lambdaArgs.asInstanceOf[List[Term]]).toMap new TreeMap { - override def transformTerm(tree: Term)(given ctx: Context): Term = + override def transformTerm(tree: Term)(using ctx: Context): Term = tree match case tree: Ident => summon[Env].get(tree.symbol).flatMap(argsMap.get).getOrElse(tree) case tree => super.transformTerm(tree) @@ -313,13 +313,13 @@ private[quoted] object Matcher { private object ClosedPatternTerm { /** Matches a term that does not contain free variables defined in the pattern (i.e. not defined in `Env`) */ - def unapply(term: Term)(given Context, Env): Option[term.type] = + def unapply(term: Term)(using Context, Env): Option[term.type] = if freePatternVars(term).isEmpty then Some(term) else None /** Return all free variables of the term defined in the pattern (i.e. defined in `Env`) */ - def freePatternVars(term: Term)(given ctx: Context, env: Env): Set[Symbol] = + def freePatternVars(term: Term)(using ctx: Context, env: Env): Set[Symbol] = val accumulator = new TreeAccumulator[Set[Symbol]] { - def foldTree(x: Set[Symbol], tree: Tree)(given ctx: Context): Set[Symbol] = + def foldTree(x: Set[Symbol], tree: Tree)(using ctx: Context): Set[Symbol] = tree match case tree: Ident if env.contains(tree.symbol) => foldOverTree(x + tree.symbol, tree) case _ => foldOverTree(x, tree) @@ -328,7 +328,7 @@ private[quoted] object Matcher { } private object IdentArgs { - def unapply(args: List[Term])(given Context): Option[List[Ident]] = + def unapply(args: List[Term])(using Context): Option[List[Ident]] = args.foldRight(Option(List.empty[Ident])) { case (id: Ident, Some(acc)) => Some(id :: acc) case (Block(List(DefDef("$anonfun", Nil, List(params), Inferred(), Some(Apply(id: Ident, args)))), Closure(Ident("$anonfun"), None)), Some(acc)) @@ -338,7 +338,7 @@ private[quoted] object Matcher { } } - private def treeOptMatches(scrutinee: Option[Tree], pattern: Option[Tree])(given Context, Env): Matching = { + private def treeOptMatches(scrutinee: Option[Tree], pattern: Option[Tree])(using Context, Env): Matching = { (scrutinee, pattern) match { case (Some(x), Some(y)) => x =?= y case (None, None) => matched @@ -346,7 +346,7 @@ private[quoted] object Matcher { } } - private def caseMatches(scrutinee: CaseDef, pattern: CaseDef)(given Context, Env): Matching = { + private def caseMatches(scrutinee: CaseDef, pattern: CaseDef)(using Context, Env): Matching = { val (caseEnv, patternMatch) = patternsMatches(scrutinee.pattern, pattern.pattern) withEnv(caseEnv) { patternMatch && @@ -366,7 +366,7 @@ private[quoted] object Matcher { * @return The new environment containing the bindings defined in this pattern tuppled with * `None` if it did not match or `Some(tup: Tuple)` if it matched where `tup` contains the contents of the holes. */ - private def patternsMatches(scrutinee: Tree, pattern: Tree)(given Context, Env): (Env, Matching) = (scrutinee, pattern) match { + private def patternsMatches(scrutinee: Tree, pattern: Tree)(using Context, Env): (Env, Matching) = (scrutinee, pattern) match { case (v1: Term, Unapply(TypeApply(Select(patternHole @ Ident("patternHole"), "unapply"), List(tpt)), Nil, Nil)) if patternHole.symbol.owner == summon[Context].requiredModule("scala.runtime.quoted.Matcher") => (summon[Env], matched(v1.seal)) @@ -412,7 +412,7 @@ private[quoted] object Matcher { (summon[Env], notMatched) } - private def foldPatterns(patterns1: List[Tree], patterns2: List[Tree])(given Context, Env): (Env, Matching) = { + private def foldPatterns(patterns1: List[Tree], patterns2: List[Tree])(using Context, Env): (Env, Matching) = { if (patterns1.size != patterns2.size) (summon[Env], notMatched) else patterns1.zip(patterns2).foldLeft((summon[Env], matched)) { (acc, x) => val (env, res) = patternsMatches(x._1, x._2)(given summon[Context], acc._1) diff --git a/library/src/scala/internal/quoted/Type.scala b/library/src/scala/internal/quoted/Type.scala index 0488007fdbad..e6a247a21faf 100644 --- a/library/src/scala/internal/quoted/Type.scala +++ b/library/src/scala/internal/quoted/Type.scala @@ -24,7 +24,7 @@ object Type { * @param qctx the current QuoteContext * @return None if it did not match, `Some(tup)` if it matched where `tup` contains `Type[Ti]`` */ - def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: scala.quoted.Type[_])(implicit patternType: scala.quoted.Type[_], + def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: scala.quoted.Type[_])(using patternType: scala.quoted.Type[_], hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = { import qctx.tasty.{_, given} new Matcher.QuoteMatcher[qctx.type].typeTreeMatch(scrutineeType.unseal, patternType.unseal, hasTypeSplices).asInstanceOf[Option[Tup]] diff --git a/library/src/scala/internal/quoted/Unpickler.scala b/library/src/scala/internal/quoted/Unpickler.scala index c67a2b24aba9..2fab9bfc01be 100644 --- a/library/src/scala/internal/quoted/Unpickler.scala +++ b/library/src/scala/internal/quoted/Unpickler.scala @@ -6,19 +6,19 @@ import scala.quoted.{Expr, QuoteContext, Type} object Unpickler { type PickledQuote = List[String] - type PickledExprArgs = Seq[Seq[Any] => (((given QuoteContext) => Expr[Any]) | Type[_])] + type PickledExprArgs = Seq[Seq[Any] => ((QuoteContext ?=> Expr[Any]) | Type[_])] type PickledTypeArgs = Seq[Seq[Any] => Type[_]] /** Unpickle `repr` which represents a pickled `Expr` tree, * replacing splice nodes with `args` */ - def unpickleExpr[T](repr: PickledQuote, args: PickledExprArgs): (given QuoteContext) => Expr[T] = + def unpickleExpr[T](repr: PickledQuote, args: PickledExprArgs): QuoteContext ?=> Expr[T] = summon[QuoteContext].tasty.internal.unpickleExpr(repr, args).asInstanceOf[Expr[T]] /** Unpickle `repr` which represents a pickled `Type` tree, * replacing splice nodes with `args` */ - def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): (given QuoteContext) => Type[T] = + def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): QuoteContext ?=> Type[T] = summon[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[Type[T]] } diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index bf007b939411..51277a6d44dd 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { private def impl[A, B](a: Expr[A], b: Expr[B])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{Bind => _, given, _} - val res = scala.internal.quoted.Expr.unapply[Tuple, Tuple](a)(b, true, qctx).map { tup => + val res = scala.internal.quoted.Expr.unapply[Tuple, Tuple](a)(given b, true, qctx).map { tup => tup.toArray.toList.map { case r: Expr[_] => s"Expr(${r.unseal.show})" diff --git a/tests/run-macros/quote-type-matcher/quoted_1.scala b/tests/run-macros/quote-type-matcher/quoted_1.scala index 795f53b2282c..96e8628d1609 100644 --- a/tests/run-macros/quote-type-matcher/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { private def matchesExpr[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{Bind => _, given, _} - val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(b, true, qctx).map { tup => + val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(given b, true, qctx).map { tup => tup.toArray.toList.map { case r: quoted.Type[_] => s"Type(${r.unseal.show})" From 2b3a1271203f7c76b470610242f5000db5ee2acc Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 5 Feb 2020 15:52:48 +0100 Subject: [PATCH 3/4] Update docs --- .../reference/metaprogramming/erased-terms.md | 20 ++++++------- docs/docs/reference/metaprogramming/macros.md | 28 +++++++++---------- .../docs/reference/metaprogramming/staging.md | 4 +-- .../metaprogramming/tasty-reflect.md | 6 ++-- .../other-new-features/tupled-function.md | 8 +++--- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/docs/reference/metaprogramming/erased-terms.md b/docs/docs/reference/metaprogramming/erased-terms.md index 643a581aa91d..b17a0d8292df 100644 --- a/docs/docs/reference/metaprogramming/erased-terms.md +++ b/docs/docs/reference/metaprogramming/erased-terms.md @@ -35,7 +35,7 @@ m.turnedOn.turnedOn // ERROR // State is must be Off ``` -Note that in the code above the actual implicit arguments for `IsOff` are never +Note that in the code above the actual context arguments for `IsOff` are never used at runtime; they serve only to establish the right constraints at compile time. As these terms are never used at runtime there is not real need to have them around, but they still need to be present in some form in the generated @@ -99,15 +99,15 @@ The following example is an extended implementation of a simple state machine which can be in a state `On` or `Off`. The machine can change state from `Off` to `On` with `turnedOn` only if it is currently `Off`, conversely from `On` to `Off` with `turnedOff` only if it is currently `On`. These last constraint are -captured with the `IsOff[S]` and `IsOn[S]` implicit evidence only exist for +captured with the `IsOff[S]` and `IsOn[S]` given evidence only exist for `IsOff[Off]` and `IsOn[On]`. For example, not allowing calling `turnedOff` on in an `Off` state as we would require an evidence `IsOn[Off]` that will not be found. -As the implicit evidences of `turnedOn` and `turnedOff` are not used in the +As the given evidences of `turnedOn` and `turnedOff` are not used in the bodies of those functions we can mark them as `erased`. This will remove the evidence parameters at runtime, but we would still evaluate the `isOn` and -`isOff` implicits that were found as arguments. As `isOn` and `isOff` are not +`isOff` givens that were found as arguments. As `isOn` and `isOff` are not used except as `erased` arguments, we can mark them as `erased`, hence removing the evaluation of the `isOn` and `isOff` evidences. @@ -121,21 +121,21 @@ final class Off extends State @implicitNotFound("State is must be Off") class IsOff[S <: State] object IsOff { - // def isOff will not be called at runtime for turnedOn, the compiler will only require that this evidence exists - implicit def isOff: IsOff[Off] = new IsOff[Off] + // will not be called at runtime for turnedOn, the compiler will only require that this evidence exists + given IsOff[Off] = new IsOff[Off] } @implicitNotFound("State is must be On") class IsOn[S <: State] object IsOn { - // erased val isOn will not exist at runtime, the compiler will only require that this evidence exists at compile time - erased implicit val isOn: IsOn[On] = new IsOn[On] + // will not exist at runtime, the compiler will only require that this evidence exists at compile time + erased given IsOn[On] = new IsOn[On] } class Machine[S <: State] private { // ev will disappear from both functions - def turnedOn(given erased ev: IsOff[S]): Machine[On] = new Machine[On] - def turnedOff(given erased ev: IsOn[S]): Machine[Off] = new Machine[Off] + def turnedOn(using erased ev: IsOff[S]): Machine[On] = new Machine[On] + def turnedOff(using erased ev: IsOn[S]): Machine[Off] = new Machine[Off] } object Machine { diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index ea1d9c61edd1..b16dd4d62dfc 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -36,12 +36,12 @@ import scala.quoted._ inline def assert(expr: => Boolean): Unit = ${ assertImpl('expr) } -def assertImpl(expr: Expr[Boolean])(given QuoteContext) = '{ +def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ if (!$expr) throw new AssertionError(s"failed assertion: ${${ showExpr(expr) }}") } -def showExpr(expr: Expr[Boolean])(given QuoteContext): Expr[String] = +def showExpr(expr: Expr[Boolean])(using QuoteContext): Expr[String] = '{ "" } // Better implementation later in this document ``` @@ -171,7 +171,7 @@ Indeed, the definition of `reflect` above uses `T` in the next stage, there is a quote but no splice between the parameter binding of `T` and its usage. But the code can be rewritten by adding a binding of a `Type[T]` tag: ```scala -def reflect[T, U](f: Expr[T] => Expr[U])(given t: Type[T]): Expr[T => U] = +def reflect[T, U](f: Expr[T] => Expr[U])(using t: Type[T]): Expr[T => U] = '{ (x: $t) => ${ f('x) } } ``` In this version of `reflect`, the type of `x` is now the result of @@ -250,7 +250,7 @@ package quoted object Expr { ... - def apply[T: Liftable](x: T)(given QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) + def apply[T: Liftable](x: T)(using QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) ... } ``` @@ -304,7 +304,7 @@ analogue of lifting. Using lifting, we can now give the missing definition of `showExpr` in the introductory example: ```scala -def showExpr[T](expr: Expr[T])(given QuoteContext): Expr[String] = { +def showExpr[T](expr: Expr[T])(using QuoteContext): Expr[String] = { val code: String = expr.show Expr(code) } @@ -425,12 +425,12 @@ implementation of the `power` function that makes use of a statically known expo ```scala inline def power(x: Double, inline n: Int) = ${ powerCode('x, 'n) } -private def powerCode(x: Expr[Double], n: Expr[Int])(given QuoteContext): Expr[Double] = +private def powerCode(x: Expr[Double], n: Expr[Int])(using QuoteContext): Expr[Double] = n.getValue match case Some(m) => powerCode(x, m) case None => '{ Math.pow($x, $y) } -private def powerCode(x: Expr[Double], n: Int)(given QuoteContext): Expr[Double] = +private def powerCode(x: Expr[Double], n: Int)(using QuoteContext): Expr[Double] = if (n == 0) '{ 1.0 } else if (n == 1) x else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('y, n / 2) } } @@ -570,7 +570,7 @@ in a quote context. For this we simply provide `scala.quoted.matching.summonExpr ```scala inline def setFor[T]: Set[T] = ${ setForExpr[T] } -def setForExpr[T: Type](given QuoteContext): Expr[Set[T]] = { +def setForExpr[T: Type](using QuoteContext): Expr[Set[T]] = { summonExpr[Ordering[T]] match { case Some(ord) => '{ new TreeSet[T]()($ord) } case _ => '{ new HashSet[T] } @@ -587,7 +587,7 @@ inline method that can calculate either a value of type `Int` or a value of type ```scala inline def defaultOf(inline str: String) <: Any = ${ defaultOfImpl('str) } -def defaultOfImpl(strExpr: Expr[String])(given QuoteContext): Expr[Any] = +def defaultOfImpl(strExpr: Expr[String])(using QuoteContext): Expr[Any] = strExpr.value match case "int" => '{1} case "string" => '{"a"} @@ -627,7 +627,7 @@ In `scala.quoted.matching` contains object that can help extract values from `Ex These could be used in the following way to optimize any call to `sum` that has statically known values. ```scala inline def sum(args: =>Int*): Int = ${ sumExpr('args) } -private def sumExpr(argsExpr: Expr[Seq[Int]])(given QuoteContext): Expr[Int] = argsExpr.underlyingArgument match { +private def sumExpr(argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[Int] = argsExpr.underlyingArgument match { case ConstSeq(args) => // args is of type Seq[Int] Expr(args.sum) // precompute result of sum case ExprSeq(argExprs) => // argExprs is of type Seq[Expr[Int]] @@ -660,7 +660,7 @@ optimize { ```scala def sum(args: Int*): Int = args.sum inline def optimize(arg: Int): Int = ${ optimizeExpr('arg) } -private def optimizeExpr(body: Expr[Int])(given QuoteContext): Expr[Int] = body match { +private def optimizeExpr(body: Expr[Int])(using QuoteContext): Expr[Int] = body match { // Match a call to sum without any arguments case '{ sum() } => Expr(0) // Match a call to sum with an argument $n of type Int. n will be the Expr[Int] representing the argument. @@ -669,7 +669,7 @@ private def optimizeExpr(body: Expr[Int])(given QuoteContext): Expr[Int] = body case '{ sum(${ExprSeq(args)}: _*) } => sumExpr(args) case body => body } -private def sumExpr(args1: Seq[Expr[Int]])(given QuoteContext): Expr[Int] = { +private def sumExpr(args1: Seq[Expr[Int]])(using QuoteContext): Expr[Int] = { def flatSumArgs(arg: Expr[Int]): Seq[Expr[Int]] = arg match { case '{ sum(${ExprSeq(subArgs)}: _*) } => subArgs.flatMap(flatSumArgs) case arg => Seq(arg) @@ -692,7 +692,7 @@ private def sumExpr(args1: Seq[Expr[Int]])(given QuoteContext): Expr[Int] = { Sometimes it is necessary to get a more precise type for an expression. This can be achived using the following pattern match. ```scala -def f(exp: Expr[Any])(given QuoteContext) = +def f(exp: Expr[Any])(using QuoteContext) = expr match case '{ $x: $t } => // If the pattern match succeeds, then there is some type `T` such that @@ -707,7 +707,7 @@ This might be used to then perform an implicit search as in: ```scala inline def (sc: StringContext).showMe(args: =>Any*): String = ${ showMeExpr('sc, 'args) } -private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = { +private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext): Expr[String] = { argsExpr match { case ExprSeq(argExprs) => val argShowedExprs = argExprs.map { diff --git a/docs/docs/reference/metaprogramming/staging.md b/docs/docs/reference/metaprogramming/staging.md index 0fa1dc79bddb..8de9e2ffaa66 100644 --- a/docs/docs/reference/metaprogramming/staging.md +++ b/docs/docs/reference/metaprogramming/staging.md @@ -66,9 +66,9 @@ On the other hand `withQuoteContext` provides a `QuoteContext` without evauating ```scala package scala.quoted.staging -def run[T](expr:(given QuoteContext) => Expr[T])(given toolbox: Toolbox): T = ... +def run[T](expr: QuoteContext ?=> Expr[T])(using toolbox: Toolbox): T = ... -def withQuoteContext[T](thunk:(given QuoteContext) => T)(given toolbox: Toolbox): T = ... +def withQuoteContext[T](thunk: QuoteContext ?=> T)(using toolbox: Toolbox): T = ... ``` ## Create a new Dotty project with staging enabled diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index 250430950bb3..af3257c26192 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -28,7 +28,7 @@ import scala.quoted._ inline def natConst(x: => Int): Int = ${natConstImpl('{x})} -def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { +def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = { import qctx.tasty.{_, given} ... } @@ -43,7 +43,7 @@ respectively. It will also import all extractors and methods on TASTy Reflect trees. For example the `Literal(_)` extractor used below. ```scala -def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { +def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = { import qctx.tasty.{_, given} val xTree: Term = x.unseal xTree match { @@ -80,7 +80,7 @@ operation expression passed while calling the `macro` below. ```scala inline def macro(param: => Boolean): Unit = ${ macroImpl('param) } -def macroImpl(param: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { +def macroImpl(param: Expr[Boolean])(using qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{_, given} import util._ diff --git a/docs/docs/reference/other-new-features/tupled-function.md b/docs/docs/reference/other-new-features/tupled-function.md index f2e836803662..38a68bd77e69 100644 --- a/docs/docs/reference/other-new-features/tupled-function.md +++ b/docs/docs/reference/other-new-features/tupled-function.md @@ -28,7 +28,7 @@ The compiler will synthesize an instance of `TupledFunction[F, G]` if: * `F` is a function type of arity `N` * `G` is a function with a single tuple argument of size `N` and it's types are equal to the arguments of `F` * The return type of `F` is equal to the return type of `G` -* `F` and `G` are the same kind of function (both are `(...) => R` or both are `(given ...) => R`) +* `F` and `G` are the same kind of function (both are `(...) => R` or both are `(...) ?=> R`) * If only one of `F` or `G` is instantiated the second one is inferred. Examples @@ -43,7 +43,7 @@ Examples * @tparam Args the tuple type with the same types as the function arguments of F * @tparam R the return type of F */ -def [F, Args <: Tuple, R](f: F).tupled(given tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f) +def [F, Args <: Tuple, R](f: F).tupled(using tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f) ``` `TupledFunction` can be used to generalize the `Function.untupled` methods to functions of any arities ([full example](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-untupled.scala)) @@ -58,7 +58,7 @@ def [F, Args <: Tuple, R](f: F).tupled(given tf: TupledFunction[F, Args => R]): * @tparam Args the tuple type with the same types as the function arguments of F * @tparam R the return type of F */ -def [F, Args <: Tuple, R](f: Args => R).untupled(given tf: TupledFunction[F, Args => R]): F = tf.untupled(f) +def [F, Args <: Tuple, R](f: Args => R).untupled(using tf: TupledFunction[F, Args => R]): F = tf.untupled(f) ``` `TupledFunction` can also be used to generalize the [`Tuple1.compose`](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-compose.scala) and [`Tuple1.andThen`](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-andThen.scala) methods to compose functions of larger arities and with functions that return tuples. @@ -72,7 +72,7 @@ def [F, Args <: Tuple, R](f: Args => R).untupled(given tf: TupledFunction[F, Arg * @tparam GArgs the tuple type with the same types as the function arguments of G * @tparam R the return type of F */ -def [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F).compose(g: G)(given tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = { +def [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F).compose(g: G)(using tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = { (x: GArgs) => tf.tupled(f)(tg.tupled(g)(x)) } ``` From ceebc336da2c2eb0dff94eb4e0310b92fefe4fe8 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 5 Feb 2020 17:03:17 +0100 Subject: [PATCH 4/4] Replace given -> using --- tests/run-macros/quote-matcher-runtime/quoted_1.scala | 2 +- tests/run-macros/quote-type-matcher/quoted_1.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index 51277a6d44dd..b6b52232065d 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { private def impl[A, B](a: Expr[A], b: Expr[B])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{Bind => _, given, _} - val res = scala.internal.quoted.Expr.unapply[Tuple, Tuple](a)(given b, true, qctx).map { tup => + val res = scala.internal.quoted.Expr.unapply[Tuple, Tuple](a)(using b, true, qctx).map { tup => tup.toArray.toList.map { case r: Expr[_] => s"Expr(${r.unseal.show})" diff --git a/tests/run-macros/quote-type-matcher/quoted_1.scala b/tests/run-macros/quote-type-matcher/quoted_1.scala index 96e8628d1609..376d0e99a54f 100644 --- a/tests/run-macros/quote-type-matcher/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { private def matchesExpr[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{Bind => _, given, _} - val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(given b, true, qctx).map { tup => + val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(using b, true, qctx).map { tup => tup.toArray.toList.map { case r: quoted.Type[_] => s"Type(${r.unseal.show})"