diff --git a/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala b/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala index ffad60c81f72..954aca953ab7 100644 --- a/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala +++ b/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala @@ -9,10 +9,12 @@ import dotty.tools.tasty.TastyVersion * the class containing this symbol was generated, * null if not applicable. * @param tastyVersion The TASTy version (major, minor, experimental) + * @param tastyExplicitNulls Was this compilation unit compiled with explicit nulls? */ class CompilationUnitInfo( val associatedFile: AbstractFile, val tastyVersion: Option[TastyVersion], + val tastyExplicitNulls: Boolean ) { override def toString(): String = @@ -22,4 +24,8 @@ class CompilationUnitInfo( object CompilationUnitInfo: def apply(assocFile: AbstractFile | Null): CompilationUnitInfo | Null = if assocFile == null then null - else new CompilationUnitInfo(assocFile, tastyVersion = None) // TODO use current TASTy version + else new CompilationUnitInfo( + assocFile, + tastyVersion = None, + tastyExplicitNulls = false // TODO track explicit nulls for current compilation units (not only TASTy) + ) diff --git a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala index 196362748a75..bda49a3cb30b 100644 --- a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -424,9 +424,11 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader { def compilationUnitInfo: CompilationUnitInfo | Null = val tastyHeader = unpickler.unpickler.header + val attributes = unpickler.tastyAttributes new CompilationUnitInfo( tastyFile, tastyVersion = Some(tastyHeader.version), + tastyExplicitNulls = attributes.explicitNulls, ) def description(using Context): String = "TASTy file " + tastyFile.toString diff --git a/compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala index 239293372981..02e3fc8c04e4 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala @@ -56,6 +56,9 @@ class DottyUnpickler(bytes: Array[Byte], mode: UnpickleMode = UnpickleMode.TopLe private val attributeUnpicklerOpt = unpickler.unpickle(new AttributesSectionUnpickler) private val treeUnpickler = unpickler.unpickle(treeSectionUnpickler(posUnpicklerOpt, commentUnpicklerOpt, attributeUnpicklerOpt)).get + def tastyAttributes: Attributes = + attributeUnpicklerOpt.map(_.attributes).getOrElse(Attributes(false, false)) + /** Enter all toplevel classes and objects into their scopes * @param roots a set of SymDenotations that should be overwritten by unpickling */