From 6722aaaeb621d31c654bed73a87ab009a8796cc2 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 22 Nov 2023 08:10:05 +0100 Subject: [PATCH] Set explicit nulls in CompilationUnitInfo symbols from source --- .../src/dotty/tools/dotc/core/CompilationUnitInfo.scala | 8 ++++---- compiler/src/dotty/tools/dotc/typer/Namer.scala | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala b/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala index 954aca953ab7..50b1d0bc5fcd 100644 --- a/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala +++ b/compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala @@ -9,12 +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? + * @param explicitNulls This compilation unit has explicit nulls enabled? */ class CompilationUnitInfo( val associatedFile: AbstractFile, val tastyVersion: Option[TastyVersion], - val tastyExplicitNulls: Boolean + val explicitNulls: Boolean ) { override def toString(): String = @@ -22,10 +22,10 @@ class CompilationUnitInfo( } object CompilationUnitInfo: - def apply(assocFile: AbstractFile | Null): CompilationUnitInfo | Null = + def apply(assocFile: AbstractFile | Null, explicitNulls: Boolean = false): CompilationUnitInfo | Null = if assocFile == null then null else new CompilationUnitInfo( assocFile, tastyVersion = None, - tastyExplicitNulls = false // TODO track explicit nulls for current compilation units (not only TASTy) + explicitNulls = explicitNulls, ) diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 7735104bc8ee..357f0d7b41e3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -250,7 +250,7 @@ class Namer { typer: Typer => val cls = createOrRefine[ClassSymbol](tree, name, flags, ctx.owner, cls => adjustIfModule(new ClassCompleter(cls, tree)(ctx), tree), - newClassSymbol(ctx.owner, name, _, _, _, tree.nameSpan, CompilationUnitInfo(ctx.source.file))) + newClassSymbol(ctx.owner, name, _, _, _, tree.nameSpan, CompilationUnitInfo(ctx.source.file, explicitNulls = ctx.explicitNulls))) cls.completer.asInstanceOf[ClassCompleter].init() cls case tree: MemberDef =>