@@ -260,6 +260,14 @@ object Denotations {
260
260
(for ((name1, name2, idx) <- (tp1.paramNames, tp2.paramNames, tp1.paramNames.indices).zipped)
261
261
yield if (name1 == name2) name1 else tp1.companion.syntheticParamName(idx)).toList
262
262
263
+ /** Merge parameter infos. This is always dowwards via gb because that's the
264
+ * only safe direction. It's safe to assume that two method implementations
265
+ * with the same signature work on the intersection of their domains.
266
+ */
267
+ private def mergeParamInfos (tp1 : LambdaType , tp2 : LambdaType )(implicit ctx : Context ): List [tp1.PInfo ] =
268
+ tp1.paramInfos.zipWithConserve(tp2.paramInfos)(
269
+ (pi1 : Type , pi2 : Type ) => (pi1 & pi2).asInstanceOf [tp1.PInfo ])
270
+
263
271
/** Form a denotation by conjoining with denotation `that`.
264
272
*
265
273
* NoDenotations are dropped. MultiDenotations are handled by merging
@@ -326,12 +334,10 @@ object Denotations {
326
334
// and result types.
327
335
if (tp1.isInstanceOf [PolyType ] && tp2.isInstanceOf [MethodType ]) tp2
328
336
else if (tp2.isInstanceOf [PolyType ] && tp1.isInstanceOf [MethodType ]) tp1
329
- else if (ctx.typeComparer.matchingParams(tp1, tp2) &&
330
- tp1.isImplicit == tp2.isImplicit)
337
+ else
331
338
tp1.derivedLambdaType(
332
- mergeParamNames(tp1, tp2), tp1.paramInfos ,
339
+ mergeParamNames(tp1, tp2), mergeParamInfos( tp1, tp2) ,
333
340
infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
334
- else mergeConflict(tp1, tp2)
335
341
case _ =>
336
342
mergeConflict(tp1, tp2)
337
343
}
@@ -481,11 +487,9 @@ object Denotations {
481
487
}
482
488
case tp1 : MethodOrPoly =>
483
489
tp2 match {
484
- case tp2 : MethodOrPoly
485
- if ctx.typeComparer.matchingParams(tp1, tp2) &&
486
- tp1.isImplicit == tp2.isImplicit =>
490
+ case tp2 : MethodOrPoly =>
487
491
tp1.derivedLambdaType(
488
- mergeParamNames(tp1, tp2), tp1.paramInfos ,
492
+ mergeParamNames(tp1, tp2), mergeParamInfos( tp1, tp2) ,
489
493
tp1.resultType | tp2.resultType.subst(tp2, tp1))
490
494
case _ =>
491
495
mergeConflict(tp1, tp2)
0 commit comments