@@ -235,7 +235,7 @@ object Nullables:
235235 */
236236 @ tailrec def impliesNotNull (ref : TermRef ): Boolean = infos match
237237 case info :: infos1 =>
238- if info.asserted != null && info.asserted.contains(ref) then true
238+ if info.asserted == null || info.asserted.contains(ref) then true
239239 else if info.retracted.contains(ref) then false
240240 else infos1.impliesNotNull(ref)
241241 case _ =>
@@ -315,8 +315,8 @@ object Nullables:
315315 extension (tree : Tree )
316316
317317 /* The `tree` with added nullability attachment */
318- def withNotNullInfo (info : NotNullInfo ): tree.type =
319- if ! info.isEmpty then tree.putAttachment(NNInfo , info)
318+ def withNotNullInfo (info : NotNullInfo )( using Context ) : tree.type =
319+ if ctx.explicitNulls && ! info.isEmpty then tree.putAttachment(NNInfo , info)
320320 tree
321321
322322 /* Collect the nullability info from parts of `tree` */
@@ -335,13 +335,15 @@ object Nullables:
335335
336336 /* The nullability info of `tree` */
337337 def notNullInfo (using Context ): NotNullInfo =
338- val tree1 = stripInlined(tree)
339- tree1.getAttachment(NNInfo ) match
340- case Some (info) if ! ctx.erasedTypes => info
341- case _ =>
342- val nnInfo = tree1.collectNotNullInfo
343- tree1.withNotNullInfo(nnInfo)
344- nnInfo
338+ if ! ctx.explicitNulls then NotNullInfo .empty
339+ else
340+ val tree1 = stripInlined(tree)
341+ tree1.getAttachment(NNInfo ) match
342+ case Some (info) if ! ctx.erasedTypes => info
343+ case _ =>
344+ val nnInfo = tree1.collectNotNullInfo
345+ tree1.withNotNullInfo(nnInfo)
346+ nnInfo
345347
346348 /* The nullability info of `tree`, assuming it is a condition that evaluates to `c` */
347349 def notNullInfoIf (c : Boolean )(using Context ): NotNullInfo =
0 commit comments