@@ -534,22 +534,23 @@ object ProtoTypes {
534
534
newTypeVar(TypeBounds .upper(AndType (tp.widenExpr, defn.SingletonClass .typeRef)))
535
535
536
536
/** The result type of `mt`, where all references to parameters of `mt` are
537
- * replaced by either wildcards (if typevarsMissContext) or TypeParamRefs.
537
+ * replaced by either wildcards or TypeParamRefs.
538
538
*/
539
- def resultTypeApprox (mt : MethodType )(using Context ): Type =
540
- if ( mt.isResultDependent) {
539
+ def resultTypeApprox (mt : MethodType , wildcardOnly : Boolean = false )(using Context ): Type =
540
+ if mt.isResultDependent then
541
541
def replacement (tp : Type ) =
542
- if (ctx.mode.is(Mode .TypevarsMissContext ) ||
543
- ! tp.widenExpr.isValueTypeOrWildcard) WildcardType
542
+ if wildcardOnly
543
+ || ctx.mode.is(Mode .TypevarsMissContext )
544
+ || ! tp.widenExpr.isValueTypeOrWildcard
545
+ then WildcardType
544
546
else newDepTypeVar(tp)
545
547
mt.resultType.substParams(mt, mt.paramInfos.map(replacement))
546
- }
547
548
else mt.resultType
548
549
549
550
/** The normalized form of a type
550
551
* - unwraps polymorphic types, tracking their parameters in the current constraint
551
552
* - skips implicit parameters of methods and functions;
552
- * if result type depends on implicit parameter, replace with fresh type dependent parameter .
553
+ * if result type depends on implicit parameter, replace with wildcard .
553
554
* - converts non-dependent method types to the corresponding function types
554
555
* unless the expected type is an ApplyingProto or IgnoredProto.
555
556
* - dereferences parameterless method types
@@ -568,7 +569,7 @@ object ProtoTypes {
568
569
case poly : PolyType =>
569
570
normalize(constrained(poly).resultType, pt)
570
571
case mt : MethodType =>
571
- if (mt.isImplicitMethod) normalize(resultTypeApprox(mt), pt)
572
+ if (mt.isImplicitMethod) normalize(resultTypeApprox(mt, wildcardOnly = true ), pt)
572
573
else if (mt.isResultDependent) tp
573
574
else {
574
575
val rt = normalize(mt.resultType, pt)
0 commit comments