Skip to content

Commit 88200a8

Browse files
committed
Use unpickler to get pickled tasty directly
1 parent a9baef2 commit 88200a8

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -609,33 +609,18 @@ object Symbols {
609609
* This will force the info of the class.
610610
*/
611611
def tree(implicit ctx: Context): tpd.Tree /* tpd.PackageDef | tpd.TypeDef | tpd.EmptyTree */ = {
612-
load()
613-
myTree
614-
}
615-
616-
/** If this is either:
617-
* - a top-level class loaded from TASTY with `-tasty`
618-
* then return the bytes of the tasty.
619-
*/
620-
def pickled(implicit ctx: Context): Array[Byte] = {
621-
load()
622-
myTasty
623-
}
624-
625-
private def load()(implicit ctx: Context): Unit = {
626612
denot.info
627613
// TODO: Consider storing this tree like we store lazy trees for inline functions
628614
if (unpickler != null && !denot.isAbsent) {
629615
assert(myTree.isEmpty)
630616
val body = unpickler.body(ctx.addMode(Mode.ReadPositions))
631617
myTree = body.headOption.getOrElse(tpd.EmptyTree)
632-
if (ctx.settings.tasty.value)
633-
myTasty = unpickler.unpickler.bytes
634-
unpickler = null
618+
if (!ctx.settings.tasty.value)
619+
unpickler = null
635620
}
621+
myTree
636622
}
637623
private[this] var myTree: tpd.Tree /* tpd.PackageDef | tpd.TypeDef | tpd.EmptyTree */ = tpd.EmptyTree
638-
private[this] var myTasty: Array[Byte] = _
639624
private[dotc] var unpickler: tasty.DottyUnpickler = _
640625

641626
private[dotc] def registerTree(tree: tpd.TypeDef)(implicit ctx: Context): Unit = {

compiler/src/dotty/tools/dotc/fromtasty/ReadTastyTreesFromClasses.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class ReadTastyTreesFromClasses extends FrontEnd {
2828
else {
2929
val unit = CompilationUnit.mkCompilationUnit(clsd, unpickled, forceTrees = true)
3030
val cls = clsd.symbol.asClass
31-
unit.pickled += (cls -> cls.pickled)
31+
unit.pickled += (cls -> cls.unpickler.unpickler.bytes)
32+
cls.unpickler = null
3233
Some(unit)
3334
}
3435
}

0 commit comments

Comments
 (0)