Skip to content

Commit d44147b

Browse files
noti0na1olhotak
andcommitted
Apply suggestions from code review
Co-authored-by: Ondřej Lhoták <[email protected]>
1 parent 05c630a commit d44147b

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Nullables.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ object Nullables:
5252
val hiTree = if(hiTpe eq hi.typeOpt) hi else TypeTree(hiTpe)
5353
TypeBoundsTree(lo, hiTree, alias)
5454

55-
/** A set of val or var references that are known to be not null,
56-
* plus a set of variable references that are once assigned to null.
55+
/** A set of val or var references that are known to be not null
56+
* after the tree finishes executing normally (non-exceptionally),
57+
* plus a set of variable references that are ever assigned to null,
58+
* and may therefore be null if execution of the tree is interrupted
59+
* by an exception.
5760
*/
5861
case class NotNullInfo(asserted: Set[TermRef], retracted: Set[TermRef]):
5962
def isEmpty = this eq NotNullInfo.empty

Diff for: compiler/src/dotty/tools/dotc/typer/Typer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
23672367
val cases2 = cases2x.asInstanceOf[List[CaseDef]]
23682368

23692369
// It is possible to have non-exhaustive cases, and some exceptions are thrown and not caught.
2370-
// Therefore, the code in the finallizer and after the try block can only rely on the retracted
2370+
// Therefore, the code in the finalizer and after the try block can only rely on the retracted
23712371
// info from the cases' body.
23722372
if cases2.nonEmpty then
23732373
nnInfo = nnInfo.seq(cases2.map(_.notNullInfo.retractedInfo).reduce(_.alt(_)))

Diff for: tests/explicit-nulls/neg/i21380c.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test4: Int =
3333
case _ => x = ""
3434
x.length // error
3535
// Although the catch block here is exhaustive, it is possible to have non-exhaustive cases,
36-
// and some exceptions are thrown and not caught. Therefore, the code in the finallizer and
36+
// and some exceptions are thrown and not caught. Therefore, the code in the finalizer and
3737
// after the try block can only rely on the retracted info from the cases' body.
3838

3939
def test5: Int =

0 commit comments

Comments
 (0)