From 3d8aca62be831d3c8cf8f29426754d073b965858 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 22 Apr 2024 09:39:38 +0200 Subject: [PATCH] Add type argument encoding to SPLICEPATTERN Future proof for #18271. --- compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala | 4 ++++ compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 55d25eeb3654..f8a0f725ea52 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -725,10 +725,14 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) { bindings.foreach(pickleTree) } case SplicePattern(pat, args) => + val targs = Nil // SplicePattern `targs` will be added with #18271 writeByte(SPLICEPATTERN) withLength { pickleTree(pat) pickleType(tree.tpe) + for targ <- targs do + writeByte(EXPLICITtpt) + pickleTree(targ) args.foreach(pickleTree) } case Hole(_, idx, args, _) => diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index ee3c98632b95..64ea2d497295 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -1566,7 +1566,8 @@ class TreeUnpickler(reader: TastyReader, case SPLICEPATTERN => val pat = readTree() val patType = readType() - val args = until(end)(readTree()) + val (targs, args) = until(end)(readTree()).span(_.isType) + assert(targs.isEmpty, "unexpected type arguments in SPLICEPATTERN") // `targs` will be needed for #18271. Until this fearure is added they should be empty. SplicePattern(pat, args, patType) case HOLE => readHole(end, isTerm = true)