Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/pos/power-macro/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import scala.quoted.Expr

object PowerMacro {

inline def power(inline n: Long, x: Double) = ~powerCode(n, '(x))

def powerCode(n: Long, x: Expr[Double]): Expr[Double] =
if (n == 0) '(1.0)
else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } }
else '{ ~x * ~powerCode(n - 1, x) }
}
5 changes: 5 additions & 0 deletions tests/pos/power-macro/PowerInlined-1_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object PowerInlined1 {
import PowerMacro._

power(1, 5.0) // 1 quotes to unpickle
}
12 changes: 12 additions & 0 deletions tests/pos/power-macro/PowerInlined-1k_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object PowerInlined1k {
import PowerMacro._

power(9223372036854775807L, 5.0) // 125 quotes to unpickle
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
}