File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -370,15 +370,14 @@ object ProtoTypes {
370
370
if wideFormal eq formal then ctx
371
371
else ctx.withNotNullInfos(ctx.notNullInfos.retractMutables)
372
372
val locked = ctx.typerState.ownedVars
373
- val nullConver = ctx.mode.is(Mode .UnsafeNullConversion )
374
- if nullConver then
375
- val targ = typer.typedUnadapted(arg, WildcardType , locked)(using argCtx.retractMode(Mode .UnsafeNullConversion ))
376
- typer.adapt(targ, wideFormal, locked)
373
+ val targ = if ctx.mode.is(Mode .UnsafeNullConversion ) then
374
+ typer.typedUnadaptedWithBlock(arg, wideFormal, locked)
375
+ (using argCtx.retractMode(Mode .UnsafeNullConversion ))
377
376
else
378
- val targ = cacheTypedArg(arg,
377
+ cacheTypedArg(arg,
379
378
typer.typedUnadapted(_, wideFormal, locked)(using argCtx),
380
379
force = true )
381
- typer.adapt(targ, wideFormal, locked)
380
+ typer.adapt(targ, wideFormal, locked)
382
381
}
383
382
384
383
/** The type of the argument `arg`, or `NoType` if `arg` has not been typed before
Original file line number Diff line number Diff line change @@ -912,6 +912,24 @@ class Typer extends Namer
912
912
pt, localSyms(stats1))
913
913
}
914
914
915
+ def typedUnadaptedWithBlock (tree : untpd.Tree , pt : Type , locked : TypeVars )(using Context ): Tree = {
916
+ tree match {
917
+ case block : untpd.Block =>
918
+ val (stats1, exprCtx) = withoutMode(Mode .Pattern ) {
919
+ typedBlockStats(block.stats)(using ctx.fresh.setNewScope)
920
+ }
921
+ val expr1 = typedUnadaptedWithBlock(block.expr, pt.dropIfProto, locked)(using exprCtx)
922
+ val expr1Tpe = expr1.tpe
923
+ ensureNoLocalRefs(
924
+ cpy.Block (block)(stats1, expr1)
925
+ .withType(expr1Tpe)
926
+ .withNotNullInfo(stats1.foldRight(expr1.notNullInfo)(_.notNullInfo.seq(_))),
927
+ expr1Tpe, localSyms(stats1))
928
+ case _ =>
929
+ typedUnadapted(tree, pt, locked)
930
+ }
931
+ }
932
+
915
933
def escapingRefs (block : Tree , localSyms : => List [Symbol ])(using Context ): List [NamedType ] = {
916
934
lazy val locals = localSyms.toSet
917
935
block.tpe.namedPartsWith(tp => locals.contains(tp.symbol) && ! tp.isErroneous)
You can’t perform that action at this time.
0 commit comments