Skip to content

Commit 703edea

Browse files
committed
Handle HKTermLambdas in TypeComparer
1 parent 85945b0 commit 703edea

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
446446
// of an `AndType` can lead to a cascade of subtyping checks
447447
// This twist is needed to make collection/generic/ParFactory.scala compile
448448
fourthTry || compareRefinedSlow
449-
case tp1: HKTypeLambda =>
450-
// HKTypeLambdas do not have members.
449+
case tp1: HKLambda =>
450+
// HKLambdas do not have members.
451451
fourthTry
452452
case _ =>
453453
compareRefinedSlow || fourthTry
@@ -534,16 +534,16 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
534534
either(recur(tp1, tp21), recur(tp1, tp22)) || fourthTry
535535
case tp2: MethodType =>
536536
def compareMethod = tp1 match {
537-
case tp1: MethodType => compareMethodOrPoly(tp1, tp2)
537+
case tp1: MethodType => compareLambdaTypes(tp1, tp2)
538538
case _ => false
539539
}
540540
compareMethod
541-
case tp2: PolyType =>
542-
def comparePoly = tp1 match {
543-
case tp1: PolyType => compareMethodOrPoly(tp1, tp2)
541+
case tp2: LambdaType => // either HKTermLambda or PolyType
542+
def compareLambda = tp1 match {
543+
case tp1: LambdaType if tp1.companion `eq` tp2.companion => compareLambdaTypes(tp1, tp2)
544544
case _ => false
545545
}
546-
comparePoly
546+
compareLambda
547547
case tp2 @ ExprType(restpe2) =>
548548
def compareExpr = tp1 match {
549549
// We allow ()T to be a subtype of => T.
@@ -582,7 +582,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
582582
fourthTry
583583
}
584584

585-
def compareMethodOrPoly(tp1: MethodOrPoly, tp2: MethodOrPoly) =
585+
def compareLambdaTypes(tp1: LambdaType, tp2: LambdaType) =
586586
(tp1.signature consistentParams tp2.signature) &&
587587
matchingParams(tp1, tp2) &&
588588
(!tp2.isImplicitMethod || tp1.isImplicitMethod) &&
@@ -1177,7 +1177,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
11771177
/** Do lambda types `lam1` and `lam2` have parameters that have the same types
11781178
* and the same implicit status? (after renaming one set to the other)
11791179
*/
1180-
def matchingParams(lam1: MethodOrPoly, lam2: MethodOrPoly): Boolean = {
1180+
def matchingParams(lam1: LambdaType, lam2: LambdaType): Boolean = {
11811181
/** Are `syms1` and `syms2` parameter lists with pairwise equivalent types? */
11821182
def loop(formals1: List[Type], formals2: List[Type]): Boolean = formals1 match {
11831183
case formal1 :: rest1 =>

0 commit comments

Comments
 (0)