Skip to content

Commit 10a5f91

Browse files
committed
Force TASTY trees read by unpickler in FromTasty
We want to ensure that the whole tree is read at phase frontend. To achieve this, we run an empty traverser over the tree.
1 parent 9e2dd75 commit 10a5f91

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/dotty/tools/dotc/FromTasty.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import util._
1515
import Decorators._
1616
import dotty.tools.dotc.transform.Pickler
1717
import pickling.DottyUnpickler
18+
import ast.tpd._
1819

1920
/** Compiler for TASTY files.
2021
* Usage:
@@ -57,6 +58,10 @@ object FromTasty extends Driver {
5758
override def toString = s"class file $className"
5859
}
5960

61+
object force extends TreeTraverser {
62+
def traverse(tree: Tree)(implicit ctx: Context): Unit = traverseChildren(tree)
63+
}
64+
6065
class ReadTastyTreesFromClasses extends FrontEnd {
6166
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] =
6267
units.map(readTASTY)
@@ -80,6 +85,7 @@ object FromTasty extends Driver {
8085
val (List(unpickled), source) = unpickler.body(readPositions = true)
8186
val unit1 = new CompilationUnit(source)
8287
unit1.tpdTree = unpickled
88+
force.traverse(unit1.tpdTree)
8389
unit1
8490
case _ =>
8591
cannotUnpickle(s"its class file ${info.classfile} does not have a TASTY attribute")

0 commit comments

Comments
 (0)