Skip to content

Commit

Permalink
Make myNotNullInfos field private
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Jan 18, 2024
1 parent 7936264 commit bc057db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ class Namer { typer: Typer =>

protected def localContext(owner: Symbol): FreshContext = ctx.fresh.setOwner(owner).setTree(original)

var myNotNullInfos: List[NotNullInfo] | Null = null
private var myNotNullInfos: List[NotNullInfo] | Null = null

/** The context with which this completer was created */
given creationContext[T]: Context =
Expand All @@ -794,6 +794,9 @@ class Namer { typer: Typer =>
// make sure testing contexts are not captured by completers
assert(!ictx.reporter.isInstanceOf[ExploringReporter])

def setNotNullInfos(infos: List[NotNullInfo]): Unit =
myNotNullInfos = infos

protected def typeSig(sym: Symbol): Type = original match
case original: ValDef =>
if (sym.is(Module)) moduleValSig(sym)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3361,11 +3361,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
mdef.getAttachment(SymOfTree) match {
case Some(sym) => sym.infoOrCompleter match {
case completer: Namer#Completer =>
if (completer.creationContext.notNullInfos ne ctx.notNullInfos)
if completer.creationContext.notNullInfos ne ctx.notNullInfos then
// The RHS of a val def should know about not null facts established
// in preceding statements (unless the DefTree is completed ahead of time,
// then it is impossible).
completer.myNotNullInfos = ctx.notNullInfos
completer.setNotNullInfos(ctx.notNullInfos)
true
case _ =>
// If it has been completed, then it must be because there is a forward reference
Expand Down

0 comments on commit bc057db

Please sign in to comment.