Skip to content

Commit 7a34e3b

Browse files
committed
Fix ExpandPrivate when compiling from TASTY
When compiling from TASTY, `ctx.source.file` will be the TASTY file corresponding to the current compilation unit, this will never match `d.symbol.sourceFile` whose value is set from the `SourceFile` annotation in the TASTY tree. Fixed by using `ctx.owner.sourceFile` instead. The added test, `anonBridge.scala` needs this fix to work. It also needs the previous work done in this PR to give positions to unpickled symbols, otherwise it crashes in `Typer#assertPositioned` because `Bridges#addBridge` creates a tree whose position comes from a symbol.
1 parent efa8c91 commit 7a34e3b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ class ExpandPrivate extends MiniPhase with IdentityDenotTransformer { thisPhase
9090
}
9191

9292
assert(d.symbol.sourceFile != null &&
93-
isSimilar(d.symbol.sourceFile.path, ctx.source.file.path),
94-
s"private ${d.symbol.showLocated} in ${d.symbol.sourceFile} accessed from ${ctx.owner.showLocated} in ${ctx.source.file}")
93+
isSimilar(d.symbol.sourceFile.path, ctx.owner.sourceFile.path),
94+
s"private ${d.symbol.showLocated} in ${d.symbol.sourceFile} accessed from ${ctx.owner.showLocated} in ${ctx.owner.sourceFile}")
9595
d.ensureNotPrivate.installAfter(thisPhase)
9696
}
9797

tests/pos-from-tasty/anonBridge.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Test {
2+
val x: PartialFunction[Int, Int] = { case x: Int => x }
3+
}

0 commit comments

Comments
 (0)