Skip to content

Commit 1954fba

Browse files
committed
Fix owners of AsFunction applied expressions
1 parent 7be9199 commit 1954fba

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ object PickledQuotes {
143143
case tree: Ident if tree.symbol == paramSym => x1Ref().withPos(tree.pos)
144144
case _ => super.transform(tree)
145145
}
146-
}.transform(ddef.rhs)
146+
}.transform(ddef.rhs).changeOwner(ddef.symbol, ctx.owner)
147147
case Block(stats, expr) =>
148148
val applied = rec(expr)
149149
if (stats.isEmpty) applied
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
125
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

0 commit comments

Comments
 (0)