Skip to content

Commit 9652b38

Browse files
committed
Don't unpickle the body of inline defs twice
The body of an inline def appears both in its rhs and in an annotation, this commit makes sure we share the same tree for both instead of unpickling it twice.
1 parent 78a5e09 commit 9652b38

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,15 @@ class TreeUnpickler(reader: TastyReader,
729729
val localCtx = localContext(sym)
730730

731731
def readRhs(implicit ctx: Context) =
732-
if (nothingButMods(end)) EmptyTree
733-
else readLater(end, rdr => ctx => rdr.readTerm()(ctx.retractMode(Mode.InSuperCall)))
732+
if (nothingButMods(end))
733+
EmptyTree
734+
else if (sym.isInlinedMethod)
735+
// The body of an inline method is stored in an annotation, so no need to unpickle it again
736+
new Trees.Lazy[Tree] {
737+
def complete(implicit ctx: Context) = typer.Inliner.bodyToInline(sym)
738+
}
739+
else
740+
readLater(end, rdr => ctx => rdr.readTerm()(ctx.retractMode(Mode.InSuperCall)))
734741

735742
def ValDef(tpt: Tree) =
736743
ta.assignType(untpd.ValDef(sym.name.asTermName, tpt, readRhs(localCtx)), sym)

0 commit comments

Comments
 (0)