Skip to content

Commit 2acdd1f

Browse files
authored
Merge pull request #4663 from dotty-staging/fix/unpickle-inline-twice
Don't unpickle the body of inline defs twice
2 parents 42698ae + 9652b38 commit 2acdd1f

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)