@@ -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 ._
@@ -305,7 +306,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
305306 args.foreach(checkInferredWellFormed)
306307 if (fn.symbol != defn.ChildAnnot .primaryConstructor)
307308 // 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)
309314 fn match {
310315 case sel : Select =>
311316 val args1 = transform(args)
@@ -365,7 +370,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
365370 else if (tree.tpt.symbol == defn.orType)
366371 () // nothing to do
367372 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)
369378 super .transform(tree)
370379 case SingletonTypeTree (ref) =>
371380 Checking .checkRealizable(ref.tpe, ref.srcPos)
0 commit comments