Skip to content

Commit 21bae33

Browse files
committed
Harden ExpandPrivate assertion
Died with an NPE instead of failing the assert
1 parent a9c72e1 commit 21bae33

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t
8989
(i < 0 || p1(i) == separatorChar) &&
9090
(j < 0 || p1(j) == separatorChar)
9191
}
92-
assert(isSimilar(d.symbol.sourceFile.path, ctx.source.file.path),
93-
i"private ${d.symbol.showLocated} in ${d.symbol.sourceFile} accessed from ${ctx.owner.showLocated} in ${ctx.source.file}")
92+
93+
assert(d.symbol.sourceFile != null &&
94+
isSimilar(d.symbol.sourceFile.path, ctx.source.file.path),
95+
s"private ${d.symbol.showLocated} in ${d.symbol.sourceFile} accessed from ${ctx.owner.showLocated} in ${ctx.source.file}")
9496
d.ensureNotPrivate.installAfter(thisTransform)
9597
}
9698

0 commit comments

Comments
 (0)