We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 58db0c0 commit 91b54aaCopy full SHA for 91b54aa
compiler/src/dotty/tools/dotc/typer/Nullables.scala
@@ -293,7 +293,7 @@ object Nullables with
293
def computeAssignNullable()(given Context): tree.type = tree.lhs match
294
case TrackedRef(ref) =>
295
val rhstp = tree.rhs.typeOpt
296
- if (rhstp.isNullType || rhstp.isNullableUnion)
+ if (rhstp.isNullType || (curCtx.explicitNulls && rhstp.isNullableUnion))
297
// If the type of rhs is nullable (`T|Null` or `Null`), then the nullability of the
298
// lhs variable is no longer trackable. We don't need to check whether the type `T`
299
// is correct here, as typer will check it.
0 commit comments