Skip to content

Commit ae1b00d

Browse files
committed
Check that we pickle a definition before its references
... 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.
1 parent 3ab18a9 commit ae1b00d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ class TreePickler(pickler: TastyPickler) {
8989
case Some(label) =>
9090
if (label != NoAddr) writeRef(label) else pickleForwardSymRef(sym)
9191
case None =>
92-
// See pos/t1957.scala for an example where this can happen.
93-
// I believe it's a bug in typer: the type of an implicit argument refers
94-
// to a closure parameter outside the closure itself. TODO: track this down, so that we
95-
// can eliminate this case.
96-
report.log(i"pickling reference to as yet undefined $sym in ${sym.owner}", sym.srcPos)
9792
pickleForwardSymRef(sym)
9893
}
9994

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

0 commit comments

Comments
 (0)