@@ -7,6 +7,7 @@ import core._
77import dotty .tools .dotc .typer .Checking
88import dotty .tools .dotc .typer .Inliner
99import dotty .tools .dotc .typer .VarianceChecker
10+ import dotty .tools .dotc .typer .Nullables
1011import Types ._ , Contexts ._ , Names ._ , Flags ._ , DenotTransformers ._ , Phases ._
1112import SymDenotations ._ , StdNames ._ , Annotations ._ , Trees ._ , Scopes ._
1213import Decorators ._
@@ -299,7 +300,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
299300 args.foreach(checkInferredWellFormed)
300301 if (fn.symbol != defn.ChildAnnot .primaryConstructor)
301302 // Make an exception for ChildAnnot, which should really have AnyKind bounds
302- Checking .checkBounds(args, fn.tpe.widen.asInstanceOf [PolyType ])
303+ val checkCtx = if tree.attachmentOrElse(Nullables .UnsafeNullsKey , false ) then
304+ ctx.addMode(Mode .UnsafeNullsSubType )
305+ else
306+ ctx
307+ Checking .checkBounds(args, fn.tpe.widen.asInstanceOf [PolyType ])(using checkCtx)
303308 fn match {
304309 case sel : Select =>
305310 val args1 = transform(args)
@@ -359,7 +364,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
359364 else if (tree.tpt.symbol == defn.orType)
360365 () // nothing to do
361366 else
362- Checking .checkAppliedType(tree)
367+ val checkCtx = if tree.attachmentOrElse(Nullables .UnsafeNullsKey , false ) then
368+ ctx.addMode(Mode .UnsafeNullsSubType )
369+ else
370+ ctx
371+ Checking .checkAppliedType(tree)(using checkCtx)
363372 super .transform(tree)
364373 case SingletonTypeTree (ref) =>
365374 Checking .checkRealizable(ref.tpe, ref.srcPos)
0 commit comments