Skip to content

Commit 944b892

Browse files
authored
Merge pull request #4202 from dotty-staging/fix/FromStart-flags
Do not set/reset flags that are part of FromStartFlags/AfterLoadFlags
2 parents 126418f + 94a3cf2 commit 944b892

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Standard-Section: "ASTs" TopLevelStat*
198198
SCALA2X // Imported from Scala2.x
199199
DEFAULTparameterized // Method with default parameters
200200
STABLE // Method that is assumed to be stable
201+
PARAMsetter // A setter without a body named `x_=` where `x` is pickled as a PARAM
201202
Annotation
202203
203204
Annotation = ANNOTATION Length tycon_Type fullAnnotation_Term
@@ -226,8 +227,8 @@ Standard Section: "Positions" Assoc*
226227
object TastyFormat {
227228

228229
final val header = Array(0x5C, 0xA1, 0xAB, 0x1F)
229-
val MajorVersion = 5
230-
val MinorVersion = 1
230+
val MajorVersion = 6
231+
val MinorVersion = 0
231232

232233
/** Tags used to serialize names */
233234
class NameTags {
@@ -268,6 +269,7 @@ object TastyFormat {
268269
// AST tags
269270
// Cat. 1: tag
270271

272+
final val firstSimpleTreeTag = UNITconst
271273
final val UNITconst = 2
272274
final val FALSEconst = 3
273275
final val TRUEconst = 4
@@ -300,6 +302,7 @@ object TastyFormat {
300302
final val STABLE = 31
301303
final val MACRO = 32
302304
final val ERASED = 33
305+
final val PARAMsetter = 34
303306

304307
// Cat. 2: tag Nat
305308

@@ -417,15 +420,14 @@ object TastyFormat {
417420

418421
final val HOLE = 255
419422

420-
final val firstSimpleTreeTag = UNITconst
421423
final val firstNatTreeTag = SHAREDterm
422424
final val firstASTTreeTag = THIS
423425
final val firstNatASTTreeTag = IDENT
424426
final val firstLengthTreeTag = PACKAGE
425427

426428
/** Useful for debugging */
427429
def isLegalTag(tag: Int) =
428-
firstSimpleTreeTag <= tag && tag <= ERASED ||
430+
firstSimpleTreeTag <= tag && tag <= PARAMsetter ||
429431
firstNatTreeTag <= tag && tag <= SYMBOLconst ||
430432
firstASTTreeTag <= tag && tag <= SINGLETONtpt ||
431433
firstNatASTTreeTag <= tag && tag <= NAMEDARG ||
@@ -463,6 +465,7 @@ object TastyFormat {
463465
| SCALA2X
464466
| DEFAULTparameterized
465467
| STABLE
468+
| PARAMsetter
466469
| ANNOTATION
467470
| PRIVATEqualified
468471
| PROTECTEDqualified => true
@@ -518,6 +521,7 @@ object TastyFormat {
518521
case SCALA2X => "SCALA2X"
519522
case DEFAULTparameterized => "DEFAULTparameterized"
520523
case STABLE => "STABLE"
524+
case PARAMsetter => "PARAMsetter"
521525

522526
case SHAREDterm => "SHAREDterm"
523527
case SHAREDtype => "SHAREDtype"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ class TreePickler(pickler: TastyPickler) {
601601
if (flags is CaseAccessor) writeByte(CASEaccessor)
602602
if (flags is DefaultParameterized) writeByte(DEFAULTparameterized)
603603
if (flags is Stable) writeByte(STABLE)
604+
if ((flags is ParamAccessor) && sym.isSetter) writeByte(PARAMsetter)
604605
} else {
605606
if (flags is Sealed) writeByte(SEALED)
606607
if (flags is Abstract) writeByte(ABSTRACT)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,11 @@ class TreeUnpickler(reader: TastyReader,
424424
flags = flags | (if (tag == VALDEF) ModuleValCreationFlags else ModuleClassCreationFlags)
425425
if (ctx.owner.isClass) {
426426
if (tag == TYPEPARAM) flags |= Param
427-
else if (tag == PARAM) flags |= ParamAccessor
427+
else if (tag == PARAM) {
428+
flags |= ParamAccessor
429+
if (!rhsIsEmpty) // param alias
430+
flags |= Method
431+
}
428432
}
429433
else if (isParamTag(tag)) flags |= Param
430434
flags
@@ -585,6 +589,8 @@ class TreeUnpickler(reader: TastyReader,
585589
case SCALA2X => addFlag(Scala2x)
586590
case DEFAULTparameterized => addFlag(DefaultParameterized)
587591
case STABLE => addFlag(Stable)
592+
case PARAMsetter =>
593+
addFlag(ParamAccessor)
588594
case PRIVATEqualified =>
589595
readByte()
590596
privateWithin = readType().typeSymbol
@@ -728,11 +734,6 @@ class TreeUnpickler(reader: TastyReader,
728734
vparamss.nestedMap(_.symbol), name == nme.CONSTRUCTOR)
729735
val resType = ctx.effectiveResultType(sym, typeParams, tpt.tpe)
730736
sym.info = ctx.methodType(typeParams, valueParamss, resType)
731-
if (sym.isSetter && sym.accessedFieldOrGetter.is(ParamAccessor)) {
732-
// reconstitute ParamAccessor flag of setters for var parameters, which is not pickled
733-
sym.setFlag(ParamAccessor)
734-
sym.resetFlag(Deferred)
735-
}
736737
DefDef(tparams, vparamss, tpt)
737738
case VALDEF =>
738739
val tpt = readTpt()(localCtx)
@@ -775,7 +776,6 @@ class TreeUnpickler(reader: TastyReader,
775776
ValDef(tpt)
776777
}
777778
else {
778-
sym.setFlag(Method)
779779
sym.info = ExprType(tpt.tpe)
780780
pickling.println(i"reading param alias $name -> $currentAddr")
781781
DefDef(Nil, Nil, tpt)

0 commit comments

Comments
 (0)