Skip to content

Honor language imports when unpickling #14962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,16 @@ class TreeUnpickler(reader: TastyReader,
Nil

def readIndexedStats(exprOwner: Symbol, end: Addr)(using Context): List[Tree] =
until(end)(readIndexedStat(exprOwner))
val buf = new mutable.ListBuffer[Tree]
var curCtx = ctx
while currentAddr.index < end.index do
val stat = readIndexedStat(exprOwner)(using curCtx)
buf += stat
stat match
case stat: Import => curCtx = ctx.importContext(stat, stat.symbol)
case _ =>
assert(currentAddr.index == end.index)
buf.toList

def readStats(exprOwner: Symbol, end: Addr)(using Context): List[Tree] = {
fork.indexStats(end)
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i14947.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.language.unsafeNulls
class C {
def g: String | Null = ???

def f =
if ??? then "" else g
}