diff --git a/compiler/src/dotty/tools/dotc/core/tasty/AttributePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/AttributePickler.scala index 869081e7b9bc..806baacaf822 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/AttributePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/AttributePickler.scala @@ -6,6 +6,7 @@ import dotty.tools.tasty.TastyBuffer import dotty.tools.tasty.TastyFormat.AttributesSection import java.nio.charset.StandardCharsets +import dotty.tools.tasty.TastyFormat object AttributePickler: diff --git a/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala index 85d2e64e9593..1dc3792c3807 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala @@ -13,6 +13,8 @@ class AttributeUnpickler(reader: TastyReader): private[tasty] lazy val attributes: List[String] = { val attributesBuilder = List.newBuilder[String] while (!isAtEnd) { + val kind = readNat() + assert(kind == TastyFormat.FLAGattr, "Malformed attribute kind") val length = readNat() val bytes = readBytes(length) val attribute = new String(bytes, StandardCharsets.UTF_8) diff --git a/tasty/src/dotty/tools/tasty/TastyFormat.scala b/tasty/src/dotty/tools/tasty/TastyFormat.scala index 887109d16cf0..34734d5093b8 100644 --- a/tasty/src/dotty/tools/tasty/TastyFormat.scala +++ b/tasty/src/dotty/tools/tasty/TastyFormat.scala @@ -270,7 +270,7 @@ Standard Section: "Comments" Comment* Standard Section: "Attributes" Attribute* ```none - Attribute = UTF8 // attributes match the regex [a-zA-Z0-9]+ + Attribute = FLAGattr UTF8 // attributes match the regex [a-zA-Z0-9]+ ``` **************************************************************************************/ @@ -606,6 +606,11 @@ object TastyFormat { final val firstNatASTTreeTag = IDENT final val firstLengthTreeTag = PACKAGE + + // Attribute tags + + final val FLAGattr = 1 + /** Useful for debugging */ def isLegalTag(tag: Int): Boolean = firstSimpleTreeTag <= tag && tag <= SPLITCLAUSE ||