@@ -7,6 +7,7 @@ import core._
7
7
import dotty .tools .dotc .typer .Checking
8
8
import dotty .tools .dotc .typer .Inliner
9
9
import dotty .tools .dotc .typer .VarianceChecker
10
+ import dotty .tools .dotc .typer .Nullables
10
11
import Types ._ , Contexts ._ , Names ._ , Flags ._ , DenotTransformers ._ , Phases ._
11
12
import SymDenotations ._ , StdNames ._ , Annotations ._ , Trees ._ , Scopes ._
12
13
import Decorators ._
@@ -305,7 +306,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
305
306
args.foreach(checkInferredWellFormed)
306
307
if (fn.symbol != defn.ChildAnnot .primaryConstructor)
307
308
// Make an exception for ChildAnnot, which should really have AnyKind bounds
308
- Checking .checkBounds(args, fn.tpe.widen.asInstanceOf [PolyType ])
309
+ val checkCtx = if tree.attachmentOrElse(Nullables .UnsafeNullsKey , false ) then
310
+ ctx.addMode(Mode .UnsafeNullsSubType )
311
+ else
312
+ ctx
313
+ Checking .checkBounds(args, fn.tpe.widen.asInstanceOf [PolyType ])(using checkCtx)
309
314
fn match {
310
315
case sel : Select =>
311
316
val args1 = transform(args)
@@ -365,7 +370,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
365
370
else if (tree.tpt.symbol == defn.orType)
366
371
() // nothing to do
367
372
else
368
- Checking .checkAppliedType(tree)
373
+ val checkCtx = if tree.attachmentOrElse(Nullables .UnsafeNullsKey , false ) then
374
+ ctx.addMode(Mode .UnsafeNullsSubType )
375
+ else
376
+ ctx
377
+ Checking .checkAppliedType(tree)(using checkCtx)
369
378
super .transform(tree)
370
379
case SingletonTypeTree (ref) =>
371
380
Checking .checkRealizable(ref.tpe, ref.srcPos)
0 commit comments