@@ -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)
0 commit comments