@@ -310,12 +310,26 @@ object Denotations {
310
310
}
311
311
case tp1 : MethodOrPoly =>
312
312
tp2 match {
313
- case tp2 : MethodOrPoly
314
- if ctx.typeComparer.matchingParams(tp1, tp2) &&
315
- tp1.isImplicit == tp2.isImplicit =>
316
- tp1.derivedLambdaType(
317
- mergeParamNames(tp1, tp2), tp1.paramInfos,
318
- infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
313
+ case tp2 : MethodOrPoly =>
314
+ // Two remedial strategies
315
+ // 1. Prefer method types over poly types. This is necessary to handle
316
+ // overloaded definitions like the following
317
+ //
318
+ // def ++ [B >: A](xs: C[B]): D[B]
319
+ // def ++ (xs: C[A]): D[A]
320
+ //
321
+ // (Code like this is found in the collection strawman)
322
+ // 2. In the case of two method types or two polytypes with matching
323
+ // parameters and implicit status, merge corresppnding parameter
324
+ // and result types.
325
+ if (tp1.isInstanceOf [PolyType ] && tp2.isInstanceOf [MethodType ]) tp2
326
+ else if (tp2.isInstanceOf [PolyType ] && tp1.isInstanceOf [MethodType ]) tp1
327
+ else if (ctx.typeComparer.matchingParams(tp1, tp2) &&
328
+ tp1.isImplicit == tp2.isImplicit)
329
+ tp1.derivedLambdaType(
330
+ mergeParamNames(tp1, tp2), tp1.paramInfos,
331
+ infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
332
+ else mergeConflict(tp1, tp2)
319
333
case _ =>
320
334
mergeConflict(tp1, tp2)
321
335
}
0 commit comments