Skip to content

Commit 86d931a

Browse files
committed
Make sure all modifier tags are recognized as such
1 parent 430cac5 commit 86d931a

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

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

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -630,44 +630,48 @@ class TreePickler(pickler: TastyPickler) {
630630

631631
def pickleFlags(flags: FlagSet, isTerm: Boolean)(implicit ctx: Context): Unit = {
632632
import Flags._
633-
if (flags is Private) writeByte(PRIVATE)
634-
if (flags is Protected) writeByte(PROTECTED)
635-
if (flags.is(Final, butNot = Module)) writeByte(FINAL)
636-
if (flags is Case) writeByte(CASE)
637-
if (flags is Override) writeByte(OVERRIDE)
638-
if (flags is Inline) writeByte(INLINE)
639-
if (flags is InlineProxy) writeByte(INLINEPROXY)
640-
if (flags is Macro) writeByte(MACRO)
641-
if (flags is JavaStatic) writeByte(STATIC)
642-
if (flags is Module) writeByte(OBJECT)
643-
if (flags is Enum) writeByte(ENUM)
644-
if (flags is Local) writeByte(LOCAL)
645-
if (flags is Synthetic) writeByte(SYNTHETIC)
646-
if (flags is Artifact) writeByte(ARTIFACT)
647-
if (flags is Scala2x) writeByte(SCALA2X)
633+
def writeModTag(tag: Int) = {
634+
assert(isModifierTag(tag))
635+
writeByte(tag)
636+
}
637+
if (flags is Private) writeModTag(PRIVATE)
638+
if (flags is Protected) writeModTag(PROTECTED)
639+
if (flags.is(Final, butNot = Module)) writeModTag(FINAL)
640+
if (flags is Case) writeModTag(CASE)
641+
if (flags is Override) writeModTag(OVERRIDE)
642+
if (flags is Inline) writeModTag(INLINE)
643+
if (flags is InlineProxy) writeModTag(INLINEPROXY)
644+
if (flags is Macro) writeModTag(MACRO)
645+
if (flags is JavaStatic) writeModTag(STATIC)
646+
if (flags is Module) writeModTag(OBJECT)
647+
if (flags is Enum) writeModTag(ENUM)
648+
if (flags is Local) writeModTag(LOCAL)
649+
if (flags is Synthetic) writeModTag(SYNTHETIC)
650+
if (flags is Artifact) writeModTag(ARTIFACT)
651+
if (flags is Scala2x) writeModTag(SCALA2X)
648652
if (isTerm) {
649-
if (flags is Implicit) writeByte(IMPLICIT)
650-
if (flags is Implied) writeByte(IMPLIED)
651-
if (flags is Erased) writeByte(ERASED)
652-
if (flags.is(Lazy, butNot = Module)) writeByte(LAZY)
653-
if (flags is AbsOverride) { writeByte(ABSTRACT); writeByte(OVERRIDE) }
654-
if (flags is Mutable) writeByte(MUTABLE)
655-
if (flags is Accessor) writeByte(FIELDaccessor)
656-
if (flags is CaseAccessor) writeByte(CASEaccessor)
657-
if (flags is DefaultParameterized) writeByte(DEFAULTparameterized)
658-
if (flags is StableRealizable) writeByte(STABLE)
659-
if (flags is Extension) writeByte(EXTENSION)
660-
if (flags is Given) writeByte(GIVEN)
661-
if (flags is ParamAccessor) writeByte(PARAMsetter)
662-
if (flags is Exported) writeByte(EXPORTED)
653+
if (flags is Implicit) writeModTag(IMPLICIT)
654+
if (flags is Implied) writeModTag(IMPLIED)
655+
if (flags is Erased) writeModTag(ERASED)
656+
if (flags.is(Lazy, butNot = Module)) writeModTag(LAZY)
657+
if (flags is AbsOverride) { writeModTag(ABSTRACT); writeModTag(OVERRIDE) }
658+
if (flags is Mutable) writeModTag(MUTABLE)
659+
if (flags is Accessor) writeModTag(FIELDaccessor)
660+
if (flags is CaseAccessor) writeModTag(CASEaccessor)
661+
if (flags is DefaultParameterized) writeModTag(DEFAULTparameterized)
662+
if (flags is StableRealizable) writeModTag(STABLE)
663+
if (flags is Extension) writeModTag(EXTENSION)
664+
if (flags is Given) writeModTag(GIVEN)
665+
if (flags is ParamAccessor) writeModTag(PARAMsetter)
666+
if (flags is Exported) writeModTag(EXPORTED)
663667
assert(!(flags is Label))
664668
} else {
665-
if (flags is Sealed) writeByte(SEALED)
666-
if (flags is Abstract) writeByte(ABSTRACT)
667-
if (flags is Trait) writeByte(TRAIT)
668-
if (flags is Covariant) writeByte(COVARIANT)
669-
if (flags is Contravariant) writeByte(CONTRAVARIANT)
670-
if (flags is Opaque) writeByte(OPAQUE)
669+
if (flags is Sealed) writeModTag(SEALED)
670+
if (flags is Abstract) writeModTag(ABSTRACT)
671+
if (flags is Trait) writeModTag(TRAIT)
672+
if (flags is Covariant) writeModTag(COVARIANT)
673+
if (flags is Contravariant) writeModTag(CONTRAVARIANT)
674+
if (flags is Opaque) writeModTag(OPAQUE)
671675
}
672676
}
673677

0 commit comments

Comments
 (0)