Skip to content

Commit 6ca41d5

Browse files
committed
Drop Java compilation units after Typer
Java compilation units should not be retained after typer, as no code will be generated for them. All we need from them are their symbols.
1 parent 046376e commit 6ca41d5

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,24 @@ class Pickler extends Phase {
2727

2828
override def run(implicit ctx: Context): Unit = {
2929
val unit = ctx.compilationUnit
30-
if (!unit.isJava) {
31-
val tree = unit.tpdTree
32-
pickling.println(i"unpickling in run ${ctx.runId}")
33-
if (ctx.settings.YtestPickler.value) beforePickling(unit) = tree.show
30+
val tree = unit.tpdTree
31+
pickling.println(i"unpickling in run ${ctx.runId}")
32+
if (ctx.settings.YtestPickler.value) beforePickling(unit) = tree.show
3433

35-
val pickler = unit.pickler
36-
val treePkl = new TreePickler(pickler)
37-
treePkl.pickle(tree :: Nil)
38-
unit.addrOfTree = treePkl.buf.addrOfTree
39-
unit.addrOfSym = treePkl.addrOfSym
40-
if (tree.pos.exists)
41-
new PositionPickler(pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil, tree.pos)
34+
val pickler = unit.pickler
35+
val treePkl = new TreePickler(pickler)
36+
treePkl.pickle(tree :: Nil)
37+
unit.addrOfTree = treePkl.buf.addrOfTree
38+
unit.addrOfSym = treePkl.addrOfSym
39+
if (tree.pos.exists)
40+
new PositionPickler(pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil, tree.pos)
4241

43-
def rawBytes = // not needed right now, but useful to print raw format.
44-
unit.pickler.assembleParts().iterator.grouped(10).toList.zipWithIndex.map {
45-
case (row, i) => s"${i}0: ${row.mkString(" ")}"
46-
}
47-
// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
48-
if (pickling ne noPrinter) new TastyPrinter(pickler.assembleParts()).printContents()
49-
}
42+
def rawBytes = // not needed right now, but useful to print raw format.
43+
unit.pickler.assembleParts().iterator.grouped(10).toList.zipWithIndex.map {
44+
case (row, i) => s"${i}0: ${row.mkString(" ")}"
45+
}
46+
// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
47+
if (pickling ne noPrinter) new TastyPrinter(pickler.assembleParts()).printContents()
5048
}
5149

5250
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = {

src/dotty/tools/dotc/typer/FrontEnd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class FrontEnd extends Phase {
5151
unitContexts foreach (enterSyms(_))
5252
unitContexts foreach (typeCheck(_))
5353
record("totalTrees", ast.Trees.ntrees)
54-
unitContexts.map(_.compilationUnit)
54+
unitContexts.map(_.compilationUnit).filter(!_.isJava)
5555
}
5656

5757
override def run(implicit ctx: Context): Unit = {

0 commit comments

Comments
 (0)