From a4fc7746563423934d33d234b5f68ecb4cd3a2bb Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 21 Nov 2023 15:38:51 +0100 Subject: [PATCH] Simplify `TastyHeader` --- .../dotty/tools/dotc/core/SymbolLoaders.scala | 10 ++------ .../tools/tasty/TastyHeaderUnpickler.scala | 23 +++++++++---------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala index c5a88b45aa55..196362748a75 100644 --- a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -426,14 +426,8 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader { val tastyHeader = unpickler.unpickler.header new CompilationUnitInfo( tastyFile, - tastyVersion = Some( - TastyVersion( - tastyHeader.majorVersion, - tastyHeader.minorVersion, - tastyHeader.experimentalVersion, - ) - ) - ) + tastyVersion = Some(tastyHeader.version), + ) def description(using Context): String = "TASTy file " + tastyFile.toString diff --git a/tasty/src/dotty/tools/tasty/TastyHeaderUnpickler.scala b/tasty/src/dotty/tools/tasty/TastyHeaderUnpickler.scala index a51541192321..aa3867e1b029 100644 --- a/tasty/src/dotty/tools/tasty/TastyHeaderUnpickler.scala +++ b/tasty/src/dotty/tools/tasty/TastyHeaderUnpickler.scala @@ -8,22 +8,21 @@ import TastyFormat.{MajorVersion, MinorVersion, ExperimentalVersion, header} * The Tasty Header consists of four fields: * - uuid * - contains a hash of the sections of the TASTy file - * - majorVersion - * - matching the TASTy format version that last broke backwards compatibility - * - minorVersion - * - matching the TASTy format version that last broke forward compatibility - * - experimentalVersion - * - 0 for final compiler version - * - positive for between minor versions and forward compatibility - * is broken since the previous stable version. + * - version + * - majorVersion + * - matching the TASTy format version that last broke backwards compatibility + * - minorVersion + * - matching the TASTy format version that last broke forward compatibility + * - experimentalVersion + * - 0 for final compiler version + * - positive for between minor versions and forward compatibility + * is broken since the previous stable version. * - toolingVersion * - arbitrary string representing the tooling that produced the TASTy */ sealed abstract case class TastyHeader( uuid: UUID, - majorVersion: Int, - minorVersion: Int, - experimentalVersion: Int, + version: TastyVersion, toolingVersion: String ) @@ -156,7 +155,7 @@ class TastyHeaderUnpickler(config: UnpicklerConfig, reader: TastyReader) { }) val uuid = new UUID(readUncompressedLong(), readUncompressedLong()) - new TastyHeader(uuid, fileMajor, fileMinor, fileExperimental, toolingVersion) {} + new TastyHeader(uuid, TastyVersion(fileMajor, fileMinor, fileExperimental), toolingVersion) {} } }