From 9652b38cdeae3279e94384b6934fc3afa260e0a9 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 14 Jun 2018 23:19:07 +0200 Subject: [PATCH] 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. --- .../dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index ce955cee96c3..57ce74ab8638 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -729,8 +729,15 @@ class TreeUnpickler(reader: TastyReader, val localCtx = localContext(sym) def readRhs(implicit ctx: Context) = - if (nothingButMods(end)) EmptyTree - else readLater(end, rdr => ctx => rdr.readTerm()(ctx.retractMode(Mode.InSuperCall))) + if (nothingButMods(end)) + EmptyTree + else if (sym.isInlinedMethod) + // The body of an inline method is stored in an annotation, so no need to unpickle it again + new Trees.Lazy[Tree] { + def complete(implicit ctx: Context) = typer.Inliner.bodyToInline(sym) + } + else + readLater(end, rdr => ctx => rdr.readTerm()(ctx.retractMode(Mode.InSuperCall))) def ValDef(tpt: Tree) = ta.assignType(untpd.ValDef(sym.name.asTermName, tpt, readRhs(localCtx)), sym)