Skip to content

Commit d427397

Browse files
Update the TastyFormat for matches with sub-cases
There was a discussion between the alternatives of: - modifying the tasty format, under the assumption that the tasty in question _should_ only be emitted in an experimental tasty version; - using an annotation to avoid changes to the tasty format. This PR implements the 1st option, see #23810 for the second option.
1 parent d68dbaf commit d427397

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
590590
if (tree.isInline)
591591
if (selector.isEmpty) writeByte(IMPLICIT)
592592
else { writeByte(INLINE); pickleTree(selector) }
593-
else if tree.isSubMatch then { writeByte(LAZY); pickleTree(selector) }
593+
else if tree.isSubMatch then { writeByte(SUBMATCH); pickleTree(selector) }
594594
else pickleTree(selector)
595595
tree.cases.foreach(pickleTree)
596596
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ class TreeUnpickler(reader: TastyReader,
15511551
readByte()
15521552
InlineMatch(readTree(), readCases(end))
15531553
}
1554-
else if nextByte == LAZY then // similarly to InlineMatch we use an arbitrary Cat.1 tag
1554+
else if nextByte == SUBMATCH then
15551555
readByte()
15561556
SubMatch(readTree(), readCases(end))
15571557
else Match(readTree(), readCases(end)))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Standard-Section: "ASTs" TopLevelStat*
104104
INLINED Length expr_Term call_Term? ValOrDefDef* -- Inlined code from call, with given body `expr` and given bindings
105105
LAMBDA Length meth_Term target_Type? -- Closure over method `f` of type `target` (omitted id `target` is a function type)
106106
IF Length [INLINE] cond_Term then_Term else_Term -- inline? if cond then thenPart else elsePart
107-
MATCH Length (IMPLICIT | [INLINE] sel_Term) CaseDef* -- (inline? sel | implicit) match caseDefs
107+
MATCH Length (IMPLICIT | [INLINE | SUBMATCH] sel_Term) CaseDef* -- ((inline | if)? sel | implicit) match caseDefs
108108
TRY Length expr_Term CaseDef* finalizer_Term? -- try expr catch {casdeDef} (finally finalizer)?
109109
RETURN Length meth_ASTRef expr_Term? -- return expr?, `methASTRef` is method from which is returned
110110
WHILE Length cond_Term body_Term -- while cond do body
@@ -511,6 +511,7 @@ object TastyFormat {
511511
final val EMPTYCLAUSE = 45
512512
final val SPLITCLAUSE = 46
513513
final val TRACKED = 47
514+
final val SUBMATCH = 48 // experimental.subCases
514515

515516
// Tree Cat. 2: tag Nat
516517
final val firstNatTreeTag = SHAREDterm

0 commit comments

Comments
 (0)