Skip to content

Commit 2b059e6

Browse files
authored
Merge pull request #7703 from bishabosha/add-nameTagToString
add nameTagToString in TastyFormat
2 parents 8a6d948 + 2f2111a commit 2b059e6

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ object TastyFormat {
254254
val MajorVersion: Int = 18
255255
val MinorVersion: Int = 0
256256

257-
/** Tags used to serialize names */
257+
/** Tags used to serialize names, should update [[nameTagToString]] if a new constant is added */
258258
class NameTags {
259259
final val UTF8 = 1 // A simple name in UTF8 encoding.
260260

@@ -286,6 +286,29 @@ object TastyFormat {
286286
}
287287
object NameTags extends NameTags
288288

289+
/**Should be kept in sync with [[NameTags]]. Converts constants to a String representing their identifier,
290+
* or NotANameTag(tag) if unrecognised.
291+
*
292+
* For debugging purposes when unpickling names in a TASTy file.
293+
*/
294+
def nameTagToString(tag: Int) = {
295+
import NameTags._
296+
tag match {
297+
case UTF8 => "UTF8"
298+
case QUALIFIED => "QUALIFIED"
299+
case EXPANDED => "EXPANDED"
300+
case EXPANDPREFIX => "EXPANDPREFIX"
301+
case UNIQUE => "UNIQUE"
302+
case DEFAULTGETTER => "DEFAULTGETTER"
303+
case VARIANT => "VARIANT"
304+
case SUPERACCESSOR => "SUPERACCESSOR"
305+
case INLINEACCESSOR => "INLINEACCESSOR"
306+
case OBJECTCLASS => "OBJECTCLASS"
307+
case SIGNED => "SIGNED"
308+
case id => s"NotANameTag($id)"
309+
}
310+
}
311+
289312
// Position header
290313

291314
final val SOURCE = 4

0 commit comments

Comments
 (0)