@@ -310,12 +310,28 @@ object Denotations {
310310 }
311311 case tp1 : MethodOrPoly =>
312312 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+ //
316+ // 1. Prefer method types over poly types. This is necessary to handle
317+ // overloaded definitions like the following
318+ //
319+ // def ++ [B >: A](xs: C[B]): D[B]
320+ // def ++ (xs: C[A]): D[A]
321+ //
322+ // (Code like this is found in the collection strawman)
323+ //
324+ // 2. In the case of two method types or two polytypes with matching
325+ // parameters and implicit status, merge corresppnding parameter
326+ // and result types.
327+ if (tp1.isInstanceOf [PolyType ] && tp2.isInstanceOf [MethodType ]) tp2
328+ else if (tp2.isInstanceOf [PolyType ] && tp1.isInstanceOf [MethodType ]) tp1
329+ else if (ctx.typeComparer.matchingParams(tp1, tp2) &&
330+ tp1.isImplicit == tp2.isImplicit)
331+ tp1.derivedLambdaType(
332+ mergeParamNames(tp1, tp2), tp1.paramInfos,
333+ infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
334+ else mergeConflict(tp1, tp2)
319335 case _ =>
320336 mergeConflict(tp1, tp2)
321337 }
@@ -553,7 +569,7 @@ object Denotations {
553569 if (sd1.exists)
554570 if (sd2.exists)
555571 if (isDoubleDef(denot1.symbol, denot2.symbol)) doubleDefError(denot1, denot2)
556- else throw new TypeError (s " failure to disambiguate overloaded reference $this" )
572+ else throw new TypeError (i " failure to disambiguate overloaded reference at $this" )
557573 else sd1
558574 else sd2
559575 }
0 commit comments