diff --git a/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala b/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala index 468d0adac1ca..2e85bd8e1040 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala +++ b/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala @@ -30,17 +30,17 @@ object Main { assert(Math.pow(3, 4) == toTheFourth(3)) } - def stagedPower(n: Int): Double => Double = { + def stagedPower(n: Int): Double => Double = run { // Code representing the labmda where the recursion is unrolled based on the value of n val code = '{ (x: Double) => ${powerCode(n, '{x})}} code.show // Evaluate the contents of the code and return it's value - code.run + code } - def powerCode(n: Int, x: Expr[Double]): Expr[Double] = + def powerCode(n: Int, x: Expr[Double]) given QuoteContext: Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x else if (n < 0) throw new Exception("Negative powers not implemented. Left as a small exercise. Dont be shy, try it out.")