Skip to content

Commit

Permalink
Pickle hole targs as trees to keep positions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Apr 12, 2023
1 parent b99bd59 commit 40cee6a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
2 changes: 1 addition & 1 deletion tasty/src/dotty/tools/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down

0 comments on commit 40cee6a

Please sign in to comment.