@@ -330,15 +330,16 @@ object Nullables with
330330 def computeAssignNullable ()(given Context ): tree.type = tree.lhs match
331331 case TrackedRef (ref) =>
332332 val rhstp = tree.rhs.typeOpt
333- if (rhstp.isNullType || (curCtx.explicitNulls && rhstp.isNullableUnion))
334- // If the type of rhs is nullable (`T|Null` or `Null`), then the nullability of the
335- // lhs variable is no longer trackable. We don't need to check whether the type `T`
336- // is correct here, as typer will check it.
337- tree.withNotNullInfo(NotNullInfo (Set (), Set (ref)))
338- else if (curCtx.explicitNulls && ref.isNullableUnion)
339- // If the initial type is nullable and the assigned value is non-null,
340- // we add it to the NotNull
341- tree.withNotNullInfo(NotNullInfo (Set (ref), Set ()))
333+ if curCtx.explicitNulls && ref.isNullableUnion then
334+ if rhstp.isNullType || rhstp.isNullableUnion then
335+ // If the type of rhs is nullable (`T|Null` or `Null`), then the nullability of the
336+ // lhs variable is no longer trackable. We don't need to check whether the type `T`
337+ // is correct here, as typer will check it.
338+ tree.withNotNullInfo(NotNullInfo (Set (), Set (ref)))
339+ else
340+ // If the initial type is nullable and the assigned value is non-null,
341+ // we add it to the NotNull.
342+ tree.withNotNullInfo(NotNullInfo (Set (ref), Set ()))
342343 else tree
343344 case _ => tree
344345
0 commit comments