Skip to content

Fix #10357: Add MATCHCASEtype tag to Tasty #10362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ class TreePickler(pickler: TastyPickler) {

private def pickleNewType(tpe: Type, richTypes: Boolean)(using Context): Unit = tpe match {
case AppliedType(tycon, args) =>
writeByte(APPLIEDtype)
withLength { pickleType(tycon); args.foreach(pickleType(_)) }
if tycon.typeSymbol == defn.MatchCaseClass then
writeByte(MATCHCASEtype)
withLength { args.foreach(pickleType(_)) }
else
writeByte(APPLIEDtype)
withLength { pickleType(tycon); args.foreach(pickleType(_)) }
case ConstantType(value) =>
pickleConstant(value)
case tpe: NamedType =>
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ class TreeUnpickler(reader: TastyReader,
SuperType(readType(), readType())
case MATCHtype =>
MatchType(readType(), readType(), until(end)(readType()))
case MATCHCASEtype =>
defn.MatchCaseClass.typeRef.appliedTo(readType(), readType())
case POLYtype =>
readMethodic(_ => PolyType, _.toTypeName)
case METHODtype =>
Expand Down
7 changes: 5 additions & 2 deletions tasty/src/dotty/tools/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Standard-Section: "ASTs" TopLevelStat*
ANDtype Length left_Type right_Type -- left & right
ORtype Length left_Type right_Type -- lefgt | right
MATCHtype Length bound_Type sel_Type case_Type* -- sel match {cases} with optional upper `bound`
MATCHCASEtype Length pat_type rhs_Type -- match cases are MATCHCASEtypes or TYPELAMBDAtypes over MATCHCASEtypes
BIND Length boundName_NameRef bounds_Type -- boundName @ bounds, for type-variables defined in a type pattern
BYNAMEtype underlying_Type -- => underlying
PARAMtype Length binder_ASTRef paramNum_Nat -- A reference to parameter # paramNum in lambda type `binder`
Expand Down Expand Up @@ -253,8 +254,8 @@ Standard Section: "Comments" Comment*
object TastyFormat {

final val header: Array[Int] = Array(0x5C, 0xA1, 0xAB, 0x1F)
val MajorVersion: Int = 24
val MinorVersion: Int = 1
val MajorVersion: Int = 25
val MinorVersion: Int = 0

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

final val MATCHtype = 190
final val MATCHtpt = 191
final val MATCHCASEtype = 192

final val HOLE = 255

Expand Down Expand Up @@ -676,6 +678,7 @@ object TastyFormat {
case TYPELAMBDAtype => "TYPELAMBDAtype"
case LAMBDAtpt => "LAMBDAtpt"
case MATCHtype => "MATCHtype"
case MATCHCASEtype => "MATCHCASEtype"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think TastyPrinter will need a case too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah maybe not, I see we don't need cases for all type nodes in the printer.

case MATCHtpt => "MATCHtpt"
case PARAMtype => "PARAMtype"
case ANNOTATION => "ANNOTATION"
Expand Down