@@ -534,22 +534,23 @@ object ProtoTypes {
534534 newTypeVar(TypeBounds .upper(AndType (tp.widenExpr, defn.SingletonClass .typeRef)))
535535
536536 /** 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.
538538 */
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
541541 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
544546 else newDepTypeVar(tp)
545547 mt.resultType.substParams(mt, mt.paramInfos.map(replacement))
546- }
547548 else mt.resultType
548549
549550 /** The normalized form of a type
550551 * - unwraps polymorphic types, tracking their parameters in the current constraint
551552 * - 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 .
553554 * - converts non-dependent method types to the corresponding function types
554555 * unless the expected type is an ApplyingProto or IgnoredProto.
555556 * - dereferences parameterless method types
@@ -568,7 +569,7 @@ object ProtoTypes {
568569 case poly : PolyType =>
569570 normalize(constrained(poly).resultType, pt)
570571 case mt : MethodType =>
571- if (mt.isImplicitMethod) normalize(resultTypeApprox(mt), pt)
572+ if (mt.isImplicitMethod) normalize(resultTypeApprox(mt, wildcardOnly = true ), pt)
572573 else if (mt.isResultDependent) tp
573574 else {
574575 val rt = normalize(mt.resultType, pt)
0 commit comments