Skip to content

Commit efc3a62

Browse files
committed
Fix Java Compatible for arguments
1 parent b1d5fc6 commit efc3a62

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

compiler/src/dotty/tools/dotc/typer/Nullables.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ object Nullables:
242242
&& s != refOwner
243243
&& (s.isOneOf(Lazy | Method) // not at the rhs of lazy ValDef or in a method (or lambda)
244244
|| s.isClass // not in a class
245-
// TODO: need to check by-name parameter
246245
|| recur(s.owner))
247246

248247
refSym.is(Mutable) // if it is immutable, we don't need to check the rest conditions

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ object ProtoTypes {
141141

142142
// equals comes from case class; no need to redefine
143143
end IgnoredProto
144-
144+
145145
final class CachedIgnoredProto(ignored: Type) extends IgnoredProto(ignored)
146146

147147
object IgnoredProto:
@@ -370,10 +370,15 @@ object ProtoTypes {
370370
if wideFormal eq formal then ctx
371371
else ctx.withNotNullInfos(ctx.notNullInfos.retractMutables)
372372
val locked = ctx.typerState.ownedVars
373-
val targ = cacheTypedArg(arg,
374-
typer.typedUnadapted(_, wideFormal, locked)(using argCtx),
375-
force = true)
376-
typer.adapt(targ, wideFormal, locked)
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)
377+
else
378+
val targ = cacheTypedArg(arg,
379+
typer.typedUnadapted(_, wideFormal, locked)(using argCtx),
380+
force = true)
381+
typer.adapt(targ, wideFormal, locked)
377382
}
378383

379384
/** The type of the argument `arg`, or `NoType` if `arg` has not been typed before

0 commit comments

Comments
 (0)