Skip to content

Commit 743cc0b

Browse files
committed
Add type argument encoding to SPLICEPATTERN
Future proof for #18271.
1 parent 31fe897 commit 743cc0b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,14 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
725725
bindings.foreach(pickleTree)
726726
}
727727
case SplicePattern(pat, args) =>
728+
val targs = Nil // SplicePattern `targs` will be added with #18271
728729
writeByte(SPLICEPATTERN)
729730
withLength {
730731
pickleTree(pat)
731732
pickleType(tree.tpe)
733+
for targ <- targs do
734+
writeByte(EXPLICITtpt)
735+
pickleTree(targ)
732736
args.foreach(pickleTree)
733737
}
734738
case Hole(_, idx, args, _) =>

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,8 @@ class TreeUnpickler(reader: TastyReader,
15661566
case SPLICEPATTERN =>
15671567
val pat = readTree()
15681568
val patType = readType()
1569-
val args = until(end)(readTree())
1569+
val (targs, args) = until(end)(readTree()).span(_.isType)
1570+
assert(targs.isEmpty, "unexpected type arguments in SPLICEPATTERN") // `targs` will be needed for #18271. Until this fearure is added they should be empty.
15701571
SplicePattern(pat, args, patType)
15711572
case HOLE =>
15721573
readHole(end, isTerm = true)

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Standard-Section: "ASTs" TopLevelStat*
112112
SELECTouter Length levels_Nat qual_Term underlying_Type -- Follow `levels` outer links, starting from `qual`, with given `underlying` type
113113
QUOTE Length body_Term bodyTpe_Type -- Quoted expression `'{ body }` of a body typed as `bodyTpe`
114114
SPLICE Length expr_Term tpe_Type -- Spliced expression `${ expr }` typed as `tpe`
115-
SPLICEPATTEN Length pat_Term tpe_Type args_Term* -- Pattern splice `${pat}` or `$pat(args*)` in a quoted pattern of type `tpe`
115+
SPLICEPATTEN Length pat_Term tpe_Type targs_Type* args_Term* -- Pattern splice `${pat}` or `$pat[targs*](args*)` in a quoted pattern of type `tpe`.
116116
-- patterns:
117117
BIND Length boundName_NameRef patType_Type pat_Term -- name @ pat, wherev `patType` is the type of the bound symbol
118118
ALTERNATIVE Length alt_Term* -- alt1 | ... | altn as a pattern

0 commit comments

Comments
 (0)