Skip to content

Commit

Permalink
Check that we pickle a definition before its references
Browse files Browse the repository at this point in the history
... except for pattern-bound symbols because in `case x: List[t]` we
pickle `List[t]` before we pickle `t` itself.

The issue with t1957.scala is fixed (after staying as a TODO for 5
years!) by the level-checking improvements in the previous commits of
this PR.
  • Loading branch information
smarter committed Dec 14, 2021
1 parent 3ab18a9 commit ae1b00d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ class TreePickler(pickler: TastyPickler) {
case Some(label) =>
if (label != NoAddr) writeRef(label) else pickleForwardSymRef(sym)
case None =>
// See pos/t1957.scala for an example where this can happen.
// I believe it's a bug in typer: the type of an implicit argument refers
// to a closure parameter outside the closure itself. TODO: track this down, so that we
// can eliminate this case.
report.log(i"pickling reference to as yet undefined $sym in ${sym.owner}", sym.srcPos)
pickleForwardSymRef(sym)
}

Expand Down Expand Up @@ -206,6 +201,8 @@ class TreePickler(pickler: TastyPickler) {
}
else if (tpe.prefix == NoPrefix) {
writeByte(if (tpe.isType) TYPEREFdirect else TERMREFdirect)
if !symRefs.contains(sym) && !sym.isPatternBound && !sym.hasAnnotation(defn.QuotedRuntimePatterns_patternTypeAnnot) then
report.error(i"pickling reference to as yet undefined $tpe with symbol ${sym}", sym.srcPos)
pickleSymRef(sym)
}
else tpe.designator match {
Expand Down

0 comments on commit ae1b00d

Please sign in to comment.