Skip to content

Commit 7dc0107

Browse files
authored
Merge pull request #10362 from dotty-staging/fix-tasty
Fix #10357: Add MATCHCASEtype tag to Tasty
2 parents 8963e5f + 90cdf18 commit 7dc0107

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,12 @@ class TreePickler(pickler: TastyPickler) {
185185

186186
private def pickleNewType(tpe: Type, richTypes: Boolean)(using Context): Unit = tpe match {
187187
case AppliedType(tycon, args) =>
188-
writeByte(APPLIEDtype)
189-
withLength { pickleType(tycon); args.foreach(pickleType(_)) }
188+
if tycon.typeSymbol == defn.MatchCaseClass then
189+
writeByte(MATCHCASEtype)
190+
withLength { args.foreach(pickleType(_)) }
191+
else
192+
writeByte(APPLIEDtype)
193+
withLength { pickleType(tycon); args.foreach(pickleType(_)) }
190194
case ConstantType(value) =>
191195
pickleConstant(value)
192196
case tpe: NamedType =>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ class TreeUnpickler(reader: TastyReader,
373373
SuperType(readType(), readType())
374374
case MATCHtype =>
375375
MatchType(readType(), readType(), until(end)(readType()))
376+
case MATCHCASEtype =>
377+
defn.MatchCaseClass.typeRef.appliedTo(readType(), readType())
376378
case POLYtype =>
377379
readMethodic(_ => PolyType, _.toTypeName)
378380
case METHODtype =>

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Standard-Section: "ASTs" TopLevelStat*
158158
ANDtype Length left_Type right_Type -- left & right
159159
ORtype Length left_Type right_Type -- lefgt | right
160160
MATCHtype Length bound_Type sel_Type case_Type* -- sel match {cases} with optional upper `bound`
161+
MATCHCASEtype Length pat_type rhs_Type -- match cases are MATCHCASEtypes or TYPELAMBDAtypes over MATCHCASEtypes
161162
BIND Length boundName_NameRef bounds_Type -- boundName @ bounds, for type-variables defined in a type pattern
162163
BYNAMEtype underlying_Type -- => underlying
163164
PARAMtype Length binder_ASTRef paramNum_Nat -- A reference to parameter # paramNum in lambda type `binder`
@@ -253,8 +254,8 @@ Standard Section: "Comments" Comment*
253254
object TastyFormat {
254255

255256
final val header: Array[Int] = Array(0x5C, 0xA1, 0xAB, 0x1F)
256-
val MajorVersion: Int = 24
257-
val MinorVersion: Int = 1
257+
val MajorVersion: Int = 25
258+
val MinorVersion: Int = 0
258259

259260
/** Tags used to serialize names, should update [[nameTagToString]] if a new constant is added */
260261
class NameTags {
@@ -469,6 +470,7 @@ object TastyFormat {
469470

470471
final val MATCHtype = 190
471472
final val MATCHtpt = 191
473+
final val MATCHCASEtype = 192
472474

473475
final val HOLE = 255
474476

@@ -676,6 +678,7 @@ object TastyFormat {
676678
case TYPELAMBDAtype => "TYPELAMBDAtype"
677679
case LAMBDAtpt => "LAMBDAtpt"
678680
case MATCHtype => "MATCHtype"
681+
case MATCHCASEtype => "MATCHCASEtype"
679682
case MATCHtpt => "MATCHtpt"
680683
case PARAMtype => "PARAMtype"
681684
case ANNOTATION => "ANNOTATION"

0 commit comments

Comments
 (0)