@@ -101,7 +101,9 @@ object ProtoTypes {
101101 val mbr = if (privateOK) tp1.member(name) else tp1.nonPrivateMember(name)
102102 def qualifies (m : SingleDenotation ) =
103103 memberProto.isRef(defn.UnitClass ) ||
104- compat.normalizedCompatible(m.info, memberProto)
104+ compat.normalizedCompatible(NamedType (tp1, name, m), memberProto)
105+ // Note: can't use `m.info` here because if `m` is a method, `m.info`
106+ // loses knowledge about `m`'s default arguments.
105107 mbr match { // hasAltWith inlined for performance
106108 case mbr : SingleDenotation => mbr.exists && qualifies(mbr)
107109 case _ => mbr hasAltWith qualifies
@@ -431,6 +433,7 @@ object ProtoTypes {
431433 * - skips implicit parameters of methods and functions;
432434 * if result type depends on implicit parameter, replace with fresh type dependent parameter.
433435 * - converts non-dependent method types to the corresponding function types
436+ * unless the expected type is an ApplyingProto or IgnoredProto.
434437 * - dereferences parameterless method types
435438 * - dereferences nullary method types provided the corresponding function type
436439 * is not a subtype of the expected type.
@@ -451,8 +454,11 @@ object ProtoTypes {
451454 else {
452455 val rt = normalize(mt.resultType, pt)
453456 pt match {
454- case pt : IgnoredProto => mt
455- case pt : ApplyingProto => mt.derivedLambdaType(mt.paramNames, mt.paramInfos, rt)
457+ case pt : IgnoredProto =>
458+ tp
459+ case pt : ApplyingProto =>
460+ if (rt eq mt.resultType) tp
461+ else mt.derivedLambdaType(mt.paramNames, mt.paramInfos, rt)
456462 case _ =>
457463 val ft = defn.FunctionOf (mt.paramInfos, rt)
458464 if (mt.paramInfos.nonEmpty || ft <:< pt) ft else rt
0 commit comments