Skip to content

Commit 53563a7

Browse files
committed
use isFullyDefined
1 parent 899c5e6 commit 53563a7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ object Inferencing {
2727
* but only if the overall result of `isFullyDefined` is `true`.
2828
* Variables that are successfully minimized do not count as uninstantiated.
2929
*/
30-
def isFullyDefined(tp: Type, force: ForceDegree.Value)(using Context): Boolean =
31-
withFreshTyperState(new IsFullyDefinedAccumulator(force).process(tp), x => x)
30+
def isFullyDefined(tp: Type, force: ForceDegree.Value, ifProto: Boolean = false)(using Context): Boolean =
31+
withFreshTyperState(new IsFullyDefinedAccumulator(force, ifProto = ifProto).process(tp), x => x)
3232

3333
/** Try to fully define `tp`. Return whether constraint has changed.
3434
* Any changed constraint is kept.
@@ -161,7 +161,7 @@ object Inferencing {
161161
* Instance types can be improved by replacing covariant occurrences of Nothing
162162
* with fresh type variables, if `force` allows this in its `canImprove` implementation.
163163
*/
164-
private class IsFullyDefinedAccumulator(force: ForceDegree.Value, minimizeSelected: Boolean = false)
164+
private class IsFullyDefinedAccumulator(force: ForceDegree.Value, minimizeSelected: Boolean = false, ifProto: Boolean = false)
165165
(using Context) extends TypeAccumulator[Boolean] {
166166

167167
/** Replace toplevel-covariant occurrences (i.e. covariant without double flips)
@@ -233,8 +233,10 @@ object Inferencing {
233233
val tpd = tp.dealias
234234
if tpd ne tp then apply(x, tpd)
235235
else tp match
236-
case _: WildcardType | _: ProtoType =>
236+
case _: WildcardType =>
237237
false
238+
case tp: ProtoType =>
239+
ifProto && foldOver(x, tp)
238240
case tvar: TypeVar if !tvar.isInstantiated =>
239241
force.appliesTo(tvar)
240242
&& ctx.typerState.constraint.contains(tvar)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4363,7 +4363,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
43634363
val newCtx = ctx.fresh.setNewScope.setReporter(new reporting.ThrowingReporter(NoReporter))
43644364
val pt1 = pt.deepenProtoTrans(using newCtx)
43654365
try {
4366-
!pt1.containsWildcardTypes(using newCtx)
4366+
isFullyDefined(pt1, ForceDegree.none, ifProto = true)
43674367
} catch {
43684368
case _: UnhandledError => false
43694369
}

0 commit comments

Comments
 (0)