Skip to content

Commit

Permalink
Set explicit nulls in CompilationUnitInfo symbols from source
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Nov 22, 2023
1 parent ada4552 commit 6722aaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/core/CompilationUnitInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ 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 =
s"CompilationUnitInfo($associatedFile, $tastyVersion)"
}

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,
)
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down

0 comments on commit 6722aaa

Please sign in to comment.