@@ -466,8 +466,8 @@ inline def power(x: Double, inline n: Int) = ${ powerCode('x, 'n) }
466
466
467
467
private def powerCode (x : Expr [Double ], n : Expr [Int ])(using Quotes ): Expr [Double ] =
468
468
n.value match
469
- case Some (m) => powerCode(x, m)
470
- case None => ' { Math .pow($x, $n.toDouble) }
469
+ case Some (m) => powerCode(x, m)
470
+ case None => ' { Math .pow($x, $n.toDouble) }
471
471
472
472
private def powerCode (x : Expr [Double ], n : Int )(using Quotes ): Expr [Double ] =
473
473
if n == 0 then ' { 1.0 }
@@ -613,8 +613,8 @@ inline def setFor[T]: Set[T] = ${ setForExpr[T] }
613
613
614
614
def setForExpr [T : Type ](using Quotes ): Expr [Set [T ]] =
615
615
Expr .summon[Ordering [T ]] match
616
- case Some (ord) => ' { new TreeSet [T ]()($ord) }
617
- case _ => ' { new HashSet [T ] }
616
+ case Some (ord) => ' { new TreeSet [T ]()($ord) }
617
+ case _ => ' { new HashSet [T ] }
618
618
```
619
619
620
620
## Relationship with Whitebox Inline
@@ -628,8 +628,8 @@ transparent inline def defaultOf(inline str: String) = ${ defaultOfImpl('str) }
628
628
629
629
def defaultOfImpl (strExpr : Expr [String ])(using Quotes ): Expr [Any ] =
630
630
strExpr.valueOrError match
631
- case " int" => ' {1 }
632
- case " string" => ' {" a" }
631
+ case " int" => ' {1 }
632
+ case " string" => ' {" a" }
633
633
634
634
// in a separate file
635
635
val a : Int = defaultOf(" int" )
@@ -665,16 +665,16 @@ These could be used in the following way to optimize any call to `sum` that has
665
665
inline def sum (inline args : Int * ): Int = $ { sumExpr(' args ) }
666
666
private def sumExpr (argsExpr : Expr [Seq [Int ]])(using Quotes ): Expr [Int ] =
667
667
argsExpr match
668
- case Varargs (args @ Exprs (argValues)) =>
669
- // args is of type Seq[Expr[Int]]
670
- // argValues is of type Seq[Int]
671
- Expr (argValues.sum) // precompute result of sum
672
- case Varargs (argExprs) => // argExprs is of type Seq[Expr[Int]]
673
- val staticSum : Int = argExprs.map(_.value.getOrElse(0 )).sum
674
- val dynamicSum : Seq [Expr [Int ]] = argExprs.filter(_.value.isEmpty)
675
- dynamicSum.foldLeft(Expr (staticSum))((acc, arg) => ' { $acc + $arg })
676
- case _ =>
677
- ' { $argsExpr.sum }
668
+ case Varargs (args @ Exprs (argValues)) =>
669
+ // args is of type Seq[Expr[Int]]
670
+ // argValues is of type Seq[Int]
671
+ Expr (argValues.sum) // precompute result of sum
672
+ case Varargs (argExprs) => // argExprs is of type Seq[Expr[Int]]
673
+ val staticSum : Int = argExprs.map(_.value.getOrElse(0 )).sum
674
+ val dynamicSum : Seq [Expr [Int ]] = argExprs.filter(_.value.isEmpty)
675
+ dynamicSum.foldLeft(Expr (staticSum))((acc, arg) => ' { $acc + $arg })
676
+ case _ =>
677
+ ' { $argsExpr.sum }
678
678
```
679
679
680
680
### Quoted patterns
0 commit comments