Skip to content

Add missing flags from case bindings in TASTy #11595

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
Mar 4, 2021
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 @@ -528,10 +528,14 @@ class TreePickler(pickler: TastyPickler) {
}
}
case Bind(name, body) =>
registerDef(tree.symbol)
val sym = tree.symbol
registerDef(sym)
writeByte(BIND)
withLength {
pickleName(name); pickleType(tree.symbol.info); pickleTree(body)
pickleName(name)
pickleType(sym.info)
pickleTree(body)
pickleFlags(sym.flags &~ Case, sym.isTerm)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to allow other modifiers like annotations? Can these be on the binding or are they always on the type?

Copy link
Contributor

Choose a reason for hiding this comment

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

They should be on the type. Are there other flags on bound symbols except Implicit or Given?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not now. But I could imagine there could be a Synthetic flag added to some of those.

It may also make sense to have Erased and Inline in the future. Such as in #11598.

}
case Alternative(alts) =>
writeByte(ALTERNATIVE)
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,10 @@ class TreeUnpickler(reader: TastyReader,
val sym = symAtAddr.getOrElse(start, forkAt(start).createSymbol())
readName()
readType()
Bind(sym, readTerm())
val body = readTerm()
val (givenFlags, _, _) = readModifiers(end)
sym.setFlag(givenFlags)
Bind(sym, body)
case ALTERNATIVE =>
Alternative(until(end)(readTerm()))
case UNAPPLY =>
Expand Down
2 changes: 1 addition & 1 deletion tasty/src/dotty/tools/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Standard-Section: "ASTs" TopLevelStat*
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
BIND Length boundName_NameRef bounds_Type Modifier* -- 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`
POLYtype Length result_Type TypesNames -- A polymorphic method type `[TypesNames]result`, used in refinements
Expand Down