From 40cee6a5c55bcc22e0e58d0053a04be9cb6ed65b Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 12 Apr 2023 11:35:03 +0200 Subject: [PATCH] Pickle hole targs as trees to keep positions --- compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala | 4 +--- compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 5 ++--- tasty/src/dotty/tools/tasty/TastyFormat.scala | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 311af25379d2..84dfc2569be6 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -672,9 +672,7 @@ class TreePickler(pickler: TastyPickler) { pickleType(tpt.tpe, richTypes = true) if targs.nonEmpty then writeByte(HOLETYPES) - withLength { - targs.foreach(targ => pickleType(targ.tpe)) - } + withLength { targs.foreach(pickleTree) } args.foreach(pickleTree) } } diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 320c0da8e359..b20ec63e71d9 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -1506,10 +1506,9 @@ class TreeUnpickler(reader: TastyReader, val targs = if nextByte == HOLETYPES then readByte() - val typesEnd = readEnd() - until(typesEnd)(readType()).map(TypeTree(_)) + until(readEnd()) { readTpt() } else Nil - val args = until(end)(readTerm()) + val args = until(end) { readTerm() } TastyQuoteHole(true, idx, targs ::: args, TypeTree(tpe)).withType(tpe) def readLater[T <: AnyRef](end: Addr, op: TreeReader => Context ?=> T)(using Context): Trees.Lazy[T] = diff --git a/tasty/src/dotty/tools/tasty/TastyFormat.scala b/tasty/src/dotty/tools/tasty/TastyFormat.scala index 8688845fb707..48cb937d54a2 100644 --- a/tasty/src/dotty/tools/tasty/TastyFormat.scala +++ b/tasty/src/dotty/tools/tasty/TastyFormat.scala @@ -124,7 +124,7 @@ Standard-Section: "ASTs" TopLevelStat* SHAREDterm term_ASTRef -- Link to previously serialized term HOLE Length idx_Nat tpe_Type HoleTypes? arg_Tree* -- Splice hole with index `idx`, the type of the hole `tpe`, type arguments of the hole `targ`s and term arguments of the hole `arg`s -- Note: From 3.0 to 3.3 `args` could contain type arguments as well. This is no longer the case. - HoleTypes = HOLETYPES Length targ_Type* + HoleTypes = HOLETYPES Length targ_Tree*