Skip to content

Commit 40bb86d

Browse files
committed
Track assignments for nullability
1 parent 3a5aff6 commit 40bb86d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ object Nullables with
218218
tree.computeNullable()
219219
}.traverse(tree)
220220

221+
given (tree: Assign)
222+
def computeAssignNullable()(given Context): tree.type = tree.lhs match
223+
case TrackedRef(ref) =>
224+
tree.withNotNullInfo(NotNullInfo(Set(), Set(ref))) // TODO: refine with nullability type info
225+
case _ => tree
226+
221227
private val analyzedOps = Set(nme.EQ, nme.NE, nme.eq, nme.ne, nme.ZAND, nme.ZOR, nme.UNARY_!)
222228

223229
end Nullables

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ class Typer extends Namer
733733
val lhsBounds =
734734
TypeBounds.lower(lhsVal.symbol.info).asSeenFrom(ref.prefix, lhsVal.symbol.owner)
735735
assignType(cpy.Assign(tree)(lhs1, typed(tree.rhs, lhsBounds.loBound)))
736+
.computeAssignNullable()
736737
}
737738
else {
738739
val pre = ref.prefix

0 commit comments

Comments
 (0)