@@ -210,7 +210,7 @@ object Nullables:
210
210
*/
211
211
@ tailrec def impliesNotNull (ref : TermRef ): Boolean = infos match
212
212
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
214
214
else if info.retracted.contains(ref) then false
215
215
else infos1.impliesNotNull(ref)
216
216
case _ =>
@@ -290,8 +290,8 @@ object Nullables:
290
290
extension (tree : Tree )
291
291
292
292
/* 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)
295
295
tree
296
296
297
297
/* Collect the nullability info from parts of `tree` */
@@ -310,13 +310,15 @@ object Nullables:
310
310
311
311
/* The nullability info of `tree` */
312
312
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
320
322
321
323
/* The nullability info of `tree`, assuming it is a condition that evaluates to `c` */
322
324
def notNullInfoIf (c : Boolean )(using Context ): NotNullInfo =
0 commit comments