aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/tasty/TastyFormat.scala3
-rw-r--r--src/dotty/tools/dotc/core/tasty/TreePickler.scala13
-rw-r--r--src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala19
-rw-r--r--test/dotc/tests.scala4
4 files changed, 22 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
index fc551658b..a8725136d 100644
--- a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
+++ b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
@@ -79,6 +79,7 @@ Standard-Section: "ASTs" TopLevelStat*
NAMEDARG Length paramName_NameRef arg_Term
ASSIGN Length lhs_Term rhs_Term
BLOCK Length expr_Term Stat*
+ INLINED Length call_Term expr_Term Stat*
LAMBDA Length meth_Term target_Type
IF Length cond_Term then_Term else_Term
MATCH Length sel_Term CaseDef*
@@ -306,6 +307,7 @@ object TastyFormat {
final val MATCH = 149
final val RETURN = 150
final val TRY = 151
+ final val INLINED = 152
final val REPEATED = 153
final val BIND = 154
final val ALTERNATIVE = 155
@@ -456,6 +458,7 @@ object TastyFormat {
case LAMBDA => "LAMBDA"
case MATCH => "MATCH"
case RETURN => "RETURN"
+ case INLINED => "INLINED"
case TRY => "TRY"
case REPEATED => "REPEATED"
case BIND => "BIND"
diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala
index a5f421888..7f1895cc3 100644
--- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala
+++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala
@@ -438,15 +438,10 @@ class TreePickler(pickler: TastyPickler) {
case SeqLiteral(elems, elemtpt) =>
writeByte(REPEATED)
withLength { pickleTree(elemtpt); elems.foreach(pickleTree) }
- case tree: Inlined =>
- // Why drop Inlined info when pickling?
- // Since we never inline inside an inlined method, we know that
- // any code that continas an Inlined tree is not inlined itself.
- // So position information for inline expansion is no longer needed.
- // The only reason to keep the inline info around would be to have fine-grained
- // position information in the linker. We should come back to this
- // point once we know more what we would do with such information.
- pickleTree(Inliner.dropInlined(tree))
+ case Inlined(call, bindings, expansion) =>
+ writeByte(INLINED)
+ bindings.foreach(preRegister)
+ withLength { pickleTree(call); pickleTree(expansion); bindings.foreach(pickleTree) }
case TypeTree() =>
pickleTpt(tree)
case Bind(name, body) =>
diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
index 57c0fe32d..35613c08d 100644
--- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
+++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
@@ -905,6 +905,15 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
def readLengthTerm(): Tree = {
val end = readEnd()
+ def readBlock(mkTree: (List[Tree], Tree) => Tree): Tree = {
+ val exprReader = fork
+ skipTree()
+ val localCtx = ctx.fresh.setNewScope
+ val stats = readStats(ctx.owner, end)(localCtx)
+ val expr = exprReader.readTerm()(localCtx)
+ mkTree(stats, expr)
+ }
+
val result =
(tag: @switch) match {
case SUPER =>
@@ -937,12 +946,10 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
case ASSIGN =>
Assign(readTerm(), readTerm())
case BLOCK =>
- val exprReader = fork
- skipTree()
- val localCtx = ctx.fresh.setNewScope
- val stats = readStats(ctx.owner, end)(localCtx)
- val expr = exprReader.readTerm()(localCtx)
- Block(stats, expr)
+ readBlock(Block)
+ case INLINED =>
+ val call = readTerm()
+ readBlock((defs, expr) => Inlined(call, defs.asInstanceOf[List[MemberDef]], expr))
case IF =>
If(readTerm(), readTerm(), readTerm())
case LAMBDA =>
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index feb65021d..01539aa5a 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -28,7 +28,7 @@ class tests extends CompilerTest {
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
}
- val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler")
+ val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler", "-Yprintpos")
val twice = List("#runs", "2")
val staleSymbolError: List[String] = List()
@@ -65,7 +65,7 @@ class tests extends CompilerTest {
Directory(defaultOutputDir + "java").deleteRecursively()
}
- @Test def pickle_pickleOK = compileDir(testsDir, "pickling", "-Yprintpos" :: testPickling)
+ @Test def pickle_pickleOK = compileDir(testsDir, "pickling", testPickling)
// This directory doesn't exist anymore
// @Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
@Test def pickle_ast = compileDir(dotcDir, "ast", testPickling)