Skip to content

Commit eda8749

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

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

compiler/src/dotty/tools/dotc/typer/Nullables.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ object Nullables:
4848
val newHi = if needNullifyHi(lo.typeOpt, hiTpe) then TypeTree(OrType(hiTpe, defn.NullType, soft = false)) else hi
4949
TypeBoundsTree(lo, newHi, alias)
5050

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

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
20862086
val cases2 = cases2x.asInstanceOf[List[CaseDef]]
20872087

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

tests/explicit-nulls/neg/i21380c.scala

Lines changed: 1 addition & 1 deletion
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)