@@ -210,7 +210,7 @@ object Nullables:
210210 */
211211 @ tailrec def impliesNotNull (ref : TermRef ): Boolean = infos match
212212 case info :: infos1 =>
213- if info.asserted != null && info.asserted.contains(ref) then true
213+ if info.asserted == null || info.asserted.contains(ref) then true
214214 else if info.retracted.contains(ref) then false
215215 else infos1.impliesNotNull(ref)
216216 case _ =>
@@ -290,8 +290,8 @@ object Nullables:
290290 extension (tree : Tree )
291291
292292 /* The `tree` with added nullability attachment */
293- def withNotNullInfo (info : NotNullInfo ): tree.type =
294- if ! info.isEmpty then tree.putAttachment(NNInfo , info)
293+ def withNotNullInfo (info : NotNullInfo )( using Context ) : tree.type =
294+ if ctx.explicitNulls && ! info.isEmpty then tree.putAttachment(NNInfo , info)
295295 tree
296296
297297 /* Collect the nullability info from parts of `tree` */
@@ -310,13 +310,15 @@ object Nullables:
310310
311311 /* The nullability info of `tree` */
312312 def notNullInfo (using Context ): NotNullInfo =
313- val tree1 = stripInlined(tree)
314- tree1.getAttachment(NNInfo ) match
315- case Some (info) if ! ctx.erasedTypes => info
316- case _ =>
317- val nnInfo = tree1.collectNotNullInfo
318- tree1.withNotNullInfo(nnInfo)
319- nnInfo
313+ if ! ctx.explicitNulls then NotNullInfo .empty
314+ else
315+ val tree1 = stripInlined(tree)
316+ tree1.getAttachment(NNInfo ) match
317+ case Some (info) if ! ctx.erasedTypes => info
318+ case _ =>
319+ val nnInfo = tree1.collectNotNullInfo
320+ tree1.withNotNullInfo(nnInfo)
321+ nnInfo
320322
321323 /* The nullability info of `tree`, assuming it is a condition that evaluates to `c` */
322324 def notNullInfoIf (c : Boolean )(using Context ): NotNullInfo =
0 commit comments