Skip to content

Commit dc0f865

Browse files
authored
Merge pull request #6807 from dotty-staging/fix-sbt-dotty-quoted-example-project
Add missing QuoteContext
2 parents 35c7dcb + cf5c43d commit dc0f865

File tree

1 file changed

+3
-3
lines changed
  • sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello

1 file changed

+3
-3
lines changed

sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ object Main {
3030
assert(Math.pow(3, 4) == toTheFourth(3))
3131
}
3232

33-
def stagedPower(n: Int): Double => Double = {
33+
def stagedPower(n: Int): Double => Double = run {
3434
// Code representing the labmda where the recursion is unrolled based on the value of n
3535
val code = '{ (x: Double) => ${powerCode(n, '{x})}}
3636

3737
code.show
3838

3939
// Evaluate the contents of the code and return it's value
40-
code.run
40+
code
4141
}
4242

43-
def powerCode(n: Int, x: Expr[Double]): Expr[Double] =
43+
def powerCode(n: Int, x: Expr[Double]) given QuoteContext: Expr[Double] =
4444
if (n == 0) '{1.0}
4545
else if (n == 1) x
4646
else if (n < 0) throw new Exception("Negative powers not implemented. Left as a small exercise. Dont be shy, try it out.")

0 commit comments

Comments
 (0)