@@ -101,7 +101,9 @@ object ProtoTypes {
101
101
val mbr = if (privateOK) tp1.member(name) else tp1.nonPrivateMember(name)
102
102
def qualifies (m : SingleDenotation ) =
103
103
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.
105
107
mbr match { // hasAltWith inlined for performance
106
108
case mbr : SingleDenotation => mbr.exists && qualifies(mbr)
107
109
case _ => mbr hasAltWith qualifies
@@ -431,6 +433,7 @@ object ProtoTypes {
431
433
* - skips implicit parameters of methods and functions;
432
434
* if result type depends on implicit parameter, replace with fresh type dependent parameter.
433
435
* - converts non-dependent method types to the corresponding function types
436
+ * unless the expected type is an ApplyingProto or IgnoredProto.
434
437
* - dereferences parameterless method types
435
438
* - dereferences nullary method types provided the corresponding function type
436
439
* is not a subtype of the expected type.
@@ -451,8 +454,11 @@ object ProtoTypes {
451
454
else {
452
455
val rt = normalize(mt.resultType, pt)
453
456
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)
456
462
case _ =>
457
463
val ft = defn.FunctionOf (mt.paramInfos, rt)
458
464
if (mt.paramInfos.nonEmpty || ft <:< pt) ft else rt
0 commit comments