Skip to content

Commit 1cf9a8a

Browse files
committed
Honor language imports mode when unpickling
1 parent 53f5531 commit 1cf9a8a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,16 @@ class TreeUnpickler(reader: TastyReader,
10601060
Nil
10611061

10621062
def readIndexedStats(exprOwner: Symbol, end: Addr)(using Context): List[Tree] =
1063-
until(end)(readIndexedStat(exprOwner))
1063+
val buf = new mutable.ListBuffer[Tree]
1064+
var curCtx = ctx
1065+
while currentAddr.index < end.index do
1066+
val stat = readIndexedStat(exprOwner)(using curCtx)
1067+
buf += stat
1068+
stat match
1069+
case stat: Import => curCtx = ctx.importContext(stat, stat.symbol)
1070+
case _ =>
1071+
assert(currentAddr.index == end.index)
1072+
buf.toList
10641073

10651074
def readStats(exprOwner: Symbol, end: Addr)(using Context): List[Tree] = {
10661075
fork.indexStats(end)

tests/pos/i14947.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.language.unsafeNulls
2+
class C {
3+
def g: String | Null = ???
4+
5+
def f =
6+
if ??? then "" else g
7+
}

0 commit comments

Comments
 (0)