File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
compiler/src/dotty/tools/dotc/core/quoted Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ object PickledQuotes {
143
143
case tree : Ident if tree.symbol == paramSym => x1Ref().withPos(tree.pos)
144
144
case _ => super .transform(tree)
145
145
}
146
- }.transform(ddef.rhs)
146
+ }.transform(ddef.rhs).changeOwner(ddef.symbol, ctx.owner)
147
147
case Block (stats, expr) =>
148
148
val applied = rec(expr)
149
149
if (stats.isEmpty) applied
Original file line number Diff line number Diff line change
1
+ 125
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+
3
+ import dotty .tools .dotc .quoted .Toolbox ._
4
+
5
+ object Test {
6
+
7
+ def main (args : Array [String ]): Unit = {
8
+ println(ackermann(3 )(4 ).run)
9
+ }
10
+
11
+ def ackermann (m : Int ): Expr [Int => Int ] = {
12
+ if (m == 0 ) ' { n => n + 1 }
13
+ else ' { n =>
14
+ def `ackermann(m-1)` (n : Int ): Int = ~ ackermann(m - 1 )('(n)) // Expr[Int => Int] applied to Expr[Int]
15
+ def `ackermann(m)` (n : Int ): Int =
16
+ if (n == 0 ) `ackermann(m-1)`(1 ) else `ackermann(m-1)`(`ackermann(m)`(n - 1 ))
17
+ `ackermann(m)`(n)
18
+ }
19
+ }
20
+
21
+ }
You can’t perform that action at this time.
0 commit comments