@@ -2389,27 +2389,40 @@ object Types {
2389
2389
x => paramInfos.mapConserve(_.subst(this , x).asInstanceOf [PInfo ]),
2390
2390
x => resType.subst(this , x))
2391
2391
2392
+ protected def prefixString : String
2393
+ final override def toString = s " $prefixString( $paramNames, $paramInfos, $resType) "
2394
+ }
2395
+
2396
+ abstract class HKLambda extends CachedProxyType with LambdaType {
2397
+ final override def underlying (implicit ctx : Context ) = resType
2398
+
2399
+ final override def computeHash = doHash(paramNames, resType, paramInfos)
2400
+
2401
+ // Defined here instead of in LambdaType for efficiency
2392
2402
final override def equals (that : Any ) = that match {
2393
- case that : LambdaType =>
2403
+ case that : HKLambda =>
2394
2404
this .paramNames == that.paramNames &&
2395
2405
this .paramInfos == that.paramInfos &&
2396
2406
this .resType == that.resType &&
2397
2407
(this .companion eq that.companion)
2398
2408
case _ =>
2399
2409
false
2400
2410
}
2401
-
2402
- protected def prefixString : String
2403
- final override def toString = s " $prefixString( $paramNames, $paramInfos, $resType) "
2404
- }
2405
-
2406
- abstract class HKLambda extends CachedProxyType with LambdaType {
2407
- final override def computeHash = doHash(paramNames, resType, paramInfos)
2408
- final override def underlying (implicit ctx : Context ) = resType
2409
2411
}
2410
2412
2411
2413
abstract class MethodOrPoly extends CachedGroundType with LambdaType with TermType {
2412
2414
final override def computeHash = doHash(paramNames, resType, paramInfos)
2415
+
2416
+ // Defined here instead of in LambdaType for efficiency
2417
+ final override def equals (that : Any ) = that match {
2418
+ case that : MethodOrPoly =>
2419
+ this .paramNames == that.paramNames &&
2420
+ this .paramInfos == that.paramInfos &&
2421
+ this .resType == that.resType &&
2422
+ (this .companion eq that.companion)
2423
+ case _ =>
2424
+ false
2425
+ }
2413
2426
}
2414
2427
2415
2428
trait TermLambda extends LambdaType { thisLambdaType =>
@@ -3539,6 +3552,26 @@ object Types {
3539
3552
variance = - variance
3540
3553
derivedTypeBounds(tp, lo1, this (tp.hi))
3541
3554
3555
+ case tp : RecType =>
3556
+ derivedRecType(tp, this (tp.parent))
3557
+
3558
+ case tp : TypeVar =>
3559
+ val inst = tp.instanceOpt
3560
+ if (inst.exists) apply(inst) else tp
3561
+
3562
+ case tp : HKApply =>
3563
+ def mapArg (arg : Type , tparam : ParamInfo ): Type = {
3564
+ val saved = variance
3565
+ variance *= tparam.paramVariance
3566
+ try this (arg)
3567
+ finally variance = saved
3568
+ }
3569
+ derivedAppliedType(tp, this (tp.tycon),
3570
+ tp.args.zipWithConserve(tp.typeParams)(mapArg))
3571
+
3572
+ case tp : ExprType =>
3573
+ derivedExprType(tp, this (tp.resultType))
3574
+
3542
3575
case tp : LambdaType =>
3543
3576
def mapOverLambda = {
3544
3577
variance = - variance
@@ -3548,12 +3581,6 @@ object Types {
3548
3581
}
3549
3582
mapOverLambda
3550
3583
3551
- case tp : ExprType =>
3552
- derivedExprType(tp, this (tp.resultType))
3553
-
3554
- case tp : RecType =>
3555
- derivedRecType(tp, this (tp.parent))
3556
-
3557
3584
case tp @ SuperType (thistp, supertp) =>
3558
3585
derivedSuperType(tp, this (thistp), this (supertp))
3559
3586
@@ -3563,21 +3590,7 @@ object Types {
3563
3590
case tp : ClassInfo =>
3564
3591
mapClassInfo(tp)
3565
3592
3566
- case tp : TypeVar =>
3567
- val inst = tp.instanceOpt
3568
- if (inst.exists) apply(inst) else tp
3569
-
3570
- case tp : HKApply =>
3571
- def mapArg (arg : Type , tparam : ParamInfo ): Type = {
3572
- val saved = variance
3573
- variance *= tparam.paramVariance
3574
- try this (arg)
3575
- finally variance = saved
3576
- }
3577
- derivedAppliedType(tp, this (tp.tycon),
3578
- tp.args.zipWithConserve(tp.typeParams)(mapArg))
3579
-
3580
- case tp : AndOrType =>
3593
+ case tp : AndOrType =>
3581
3594
derivedAndOrType(tp, this (tp.tp1), this (tp.tp2))
3582
3595
3583
3596
case tp : SkolemType =>
@@ -3758,17 +3771,14 @@ object Types {
3758
3771
this (y, hi)
3759
3772
}
3760
3773
3761
- case tp : LambdaType =>
3762
- variance = - variance
3763
- val y = foldOver(x, tp.paramInfos)
3764
- variance = - variance
3765
- this (y, tp.resultType)
3774
+ case tp : RecType =>
3775
+ this (x, tp.parent)
3766
3776
3767
3777
case ExprType (restpe) =>
3768
3778
this (x, restpe)
3769
3779
3770
- case tp : RecType =>
3771
- this (x, tp.parent )
3780
+ case tp : TypeVar =>
3781
+ this (x, tp.underlying )
3772
3782
3773
3783
case SuperType (thistp, supertp) =>
3774
3784
this (this (x, thistp), supertp)
@@ -3793,6 +3803,12 @@ object Types {
3793
3803
}
3794
3804
foldArgs(this (x, tycon), tp.typeParams, args)
3795
3805
3806
+ case tp : LambdaType =>
3807
+ variance = - variance
3808
+ val y = foldOver(x, tp.paramInfos)
3809
+ variance = - variance
3810
+ this (y, tp.resultType)
3811
+
3796
3812
case tp : AndOrType =>
3797
3813
this (this (x, tp.tp1), tp.tp2)
3798
3814
@@ -3802,9 +3818,6 @@ object Types {
3802
3818
case AnnotatedType (underlying, annot) =>
3803
3819
this (applyToAnnot(x, annot), underlying)
3804
3820
3805
- case tp : TypeVar =>
3806
- this (x, tp.underlying)
3807
-
3808
3821
case tp : WildcardType =>
3809
3822
this (x, tp.optBounds)
3810
3823
0 commit comments