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