Skip to content

Do not set/reset flags that are part of FromStartFlags/AfterLoadFlags #4202

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 2 commits into from
Mar 30, 2018
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
12 changes: 8 additions & 4 deletions compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Standard-Section: "ASTs" TopLevelStat*
SCALA2X // Imported from Scala2.x
DEFAULTparameterized // Method with default parameters
STABLE // Method that is assumed to be stable
PARAMsetter // A setter without a body named `x_=` where `x` is pickled as a PARAM
Annotation

Annotation = ANNOTATION Length tycon_Type fullAnnotation_Term
Expand Down Expand Up @@ -226,8 +227,8 @@ Standard Section: "Positions" Assoc*
object TastyFormat {

final val header = Array(0x5C, 0xA1, 0xAB, 0x1F)
val MajorVersion = 5
val MinorVersion = 1
val MajorVersion = 6
val MinorVersion = 0

/** Tags used to serialize names */
class NameTags {
Expand Down Expand Up @@ -268,6 +269,7 @@ object TastyFormat {
// AST tags
// Cat. 1: tag

final val firstSimpleTreeTag = UNITconst
final val UNITconst = 2
final val FALSEconst = 3
final val TRUEconst = 4
Expand Down Expand Up @@ -300,6 +302,7 @@ object TastyFormat {
final val STABLE = 31
final val MACRO = 32
final val ERASED = 33
final val PARAMsetter = 34

// Cat. 2: tag Nat

Expand Down Expand Up @@ -417,15 +420,14 @@ object TastyFormat {

final val HOLE = 255

final val firstSimpleTreeTag = UNITconst
final val firstNatTreeTag = SHAREDterm
final val firstASTTreeTag = THIS
final val firstNatASTTreeTag = IDENT
final val firstLengthTreeTag = PACKAGE

/** Useful for debugging */
def isLegalTag(tag: Int) =
firstSimpleTreeTag <= tag && tag <= ERASED ||
firstSimpleTreeTag <= tag && tag <= PARAMsetter ||
firstNatTreeTag <= tag && tag <= SYMBOLconst ||
firstASTTreeTag <= tag && tag <= SINGLETONtpt ||
firstNatASTTreeTag <= tag && tag <= NAMEDARG ||
Expand Down Expand Up @@ -463,6 +465,7 @@ object TastyFormat {
| SCALA2X
| DEFAULTparameterized
| STABLE
| PARAMsetter
| ANNOTATION
| PRIVATEqualified
| PROTECTEDqualified => true
Expand Down Expand Up @@ -518,6 +521,7 @@ object TastyFormat {
case SCALA2X => "SCALA2X"
case DEFAULTparameterized => "DEFAULTparameterized"
case STABLE => "STABLE"
case PARAMsetter => "PARAMsetter"

case SHAREDterm => "SHAREDterm"
case SHAREDtype => "SHAREDtype"
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ class TreePickler(pickler: TastyPickler) {
if (flags is CaseAccessor) writeByte(CASEaccessor)
if (flags is DefaultParameterized) writeByte(DEFAULTparameterized)
if (flags is Stable) writeByte(STABLE)
if ((flags is ParamAccessor) && sym.isSetter) writeByte(PARAMsetter)
} else {
if (flags is Sealed) writeByte(SEALED)
if (flags is Abstract) writeByte(ABSTRACT)
Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,11 @@ class TreeUnpickler(reader: TastyReader,
flags = flags | (if (tag == VALDEF) ModuleValCreationFlags else ModuleClassCreationFlags)
if (ctx.owner.isClass) {
if (tag == TYPEPARAM) flags |= Param
else if (tag == PARAM) flags |= ParamAccessor
else if (tag == PARAM) {
flags |= ParamAccessor
if (!rhsIsEmpty) // param alias
flags |= Method
}
}
else if (isParamTag(tag)) flags |= Param
flags
Expand Down Expand Up @@ -585,6 +589,8 @@ class TreeUnpickler(reader: TastyReader,
case SCALA2X => addFlag(Scala2x)
case DEFAULTparameterized => addFlag(DefaultParameterized)
case STABLE => addFlag(Stable)
case PARAMsetter =>
addFlag(ParamAccessor)
case PRIVATEqualified =>
readByte()
privateWithin = readType().typeSymbol
Expand Down Expand Up @@ -728,11 +734,6 @@ class TreeUnpickler(reader: TastyReader,
vparamss.nestedMap(_.symbol), name == nme.CONSTRUCTOR)
val resType = ctx.effectiveResultType(sym, typeParams, tpt.tpe)
sym.info = ctx.methodType(typeParams, valueParamss, resType)
if (sym.isSetter && sym.accessedFieldOrGetter.is(ParamAccessor)) {
// reconstitute ParamAccessor flag of setters for var parameters, which is not pickled
sym.setFlag(ParamAccessor)
sym.resetFlag(Deferred)
}
DefDef(tparams, vparamss, tpt)
case VALDEF =>
val tpt = readTpt()(localCtx)
Expand Down Expand Up @@ -775,7 +776,6 @@ class TreeUnpickler(reader: TastyReader,
ValDef(tpt)
}
else {
sym.setFlag(Method)
sym.info = ExprType(tpt.tpe)
pickling.println(i"reading param alias $name -> $currentAddr")
DefDef(Nil, Nil, tpt)
Expand Down