@@ -27,8 +27,8 @@ object Inferencing {
27
27
* but only if the overall result of `isFullyDefined` is `true`.
28
28
* Variables that are successfully minimized do not count as uninstantiated.
29
29
*/
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)
32
32
33
33
/** Try to fully define `tp`. Return whether constraint has changed.
34
34
* Any changed constraint is kept.
@@ -161,7 +161,7 @@ object Inferencing {
161
161
* Instance types can be improved by replacing covariant occurrences of Nothing
162
162
* with fresh type variables, if `force` allows this in its `canImprove` implementation.
163
163
*/
164
- private class IsFullyDefinedAccumulator (force : ForceDegree .Value , minimizeSelected : Boolean = false )
164
+ private class IsFullyDefinedAccumulator (force : ForceDegree .Value , minimizeSelected : Boolean = false , ifProto : Boolean = false )
165
165
(using Context ) extends TypeAccumulator [Boolean ] {
166
166
167
167
/** Replace toplevel-covariant occurrences (i.e. covariant without double flips)
@@ -233,8 +233,10 @@ object Inferencing {
233
233
val tpd = tp.dealias
234
234
if tpd ne tp then apply(x, tpd)
235
235
else tp match
236
- case _ : WildcardType | _ : ProtoType =>
236
+ case _ : WildcardType =>
237
237
false
238
+ case tp : ProtoType =>
239
+ ifProto && foldOver(x, tp)
238
240
case tvar : TypeVar if ! tvar.isInstantiated =>
239
241
force.appliesTo(tvar)
240
242
&& ctx.typerState.constraint.contains(tvar)
0 commit comments