Skip to content

Commit 1d62624

Browse files
committed
Temporary hack to circumvent missing sourcefile info
Will be no longer necessary once bootstrap library uses new Tasty format.
1 parent 2a6efc2 commit 1d62624

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,16 @@ class TreeUnpickler(reader: TastyReader,
112112
val owner = ctx.owner
113113
val source = ctx.source
114114
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
115+
val sourceToUse = if (source.exists) source else ctx.source
116+
// TODO: remove. This is a hack to get pickling tests (notable tuple-cons-2.scala
117+
// to pass. The problem is that without a bootstrapped library some unpicked
118+
// files are lacking a source, and if these are completed from Definitions
119+
// there's also no external source given in `context`. In that case we switch
120+
// late and pick the calling context's source. We can drop this hack once
121+
// all Tasty trees have a SOURCE entry, which will determine the context source
115122
treeAtAddr(currentAddr) =
116123
new TreeReader(reader).readIndexedDef()(
117-
ctx.withPhaseNoLater(ctx.picklerPhase).withOwner(owner).withSource(source))
124+
ctx.withPhaseNoLater(ctx.picklerPhase).withOwner(owner).withSource(sourceToUse))
118125
}
119126
}
120127

0 commit comments

Comments
 (0)