@@ -2356,11 +2356,6 @@ object Types {
2356
2356
2357
2357
override def computeHash (h : Hashing ) = h.withBinder(this ).doHash(getClass, parent)
2358
2358
2359
- override def eql (that : Type ) = that match {
2360
- case that : RecType => parent.eq(that.parent)
2361
- case _ => false
2362
- }
2363
-
2364
2359
override def iso (that : Any , e : StructEquality ) = that match {
2365
2360
case that : RecType =>
2366
2361
e.withBinders(this , that).equals(parent, that.parent)
@@ -2684,37 +2679,51 @@ object Types {
2684
2679
final override def toString = s " $prefixString( $paramNames, $paramInfos, $resType) "
2685
2680
}
2686
2681
2682
+ /** Base class of HKTypeLambda. In the future could be base class of HKTermLambda
2683
+ * (aka typelevel function type) if that is added.
2684
+ */
2687
2685
abstract class HKLambda extends CachedProxyType with LambdaType {
2688
2686
final override def underlying (implicit ctx : Context ) = resType
2689
2687
2690
2688
final override def computeHash (h : Hashing ) =
2691
2689
h.withBinder(this ).doHash(getClass, paramNames, resType, paramInfos)
2692
2690
2693
- final override def eql (that : Type ) = that match {
2691
+ final override def iso (that : Any , e : StructEquality ) = that match {
2694
2692
case that : HKLambda =>
2695
- paramNames.equals(that.paramNames) &&
2696
- paramInfos.equals(that.paramInfos) &&
2697
- resType.equals(that.resType) &&
2698
- companion.eq(that.companion)
2693
+ paramNames.eqElements(that.paramNames) &&
2694
+ companion.eq(that.companion) && {
2695
+ val e1 = e.withBinders(this , that)
2696
+ e1.equals(paramInfos, that.paramInfos) &&
2697
+ e1.equals(resType, that.resType)
2698
+ }
2699
2699
case _ =>
2700
2700
false
2701
2701
}
2702
+ }
2703
+
2704
+ /** Common base class of MethodType and PolyType. It's methods are duplicated
2705
+ * from HKLambda for efficiency. Joining the two methods in the common supertrait
2706
+ * LambdaType could be slower because of trait dispatch and because the type test
2707
+ * in `iso` would be to a trait instead of a class
2708
+ */
2709
+ abstract class MethodOrPoly extends CachedGroundType with LambdaType with MethodicType {
2710
+
2711
+ final override def computeHash (h : Hashing ) =
2712
+ h.withBinder(this ).doHash(getClass, paramNames, resType, paramInfos)
2702
2713
2703
2714
final override def iso (that : Any , e : StructEquality ) = that match {
2704
- case that : HKLambda =>
2715
+ case that : MethodOrPoly =>
2705
2716
paramNames.eqElements(that.paramNames) &&
2706
2717
companion.eq(that.companion) && {
2707
2718
val e1 = e.withBinders(this , that)
2708
2719
e1.equals(paramInfos, that.paramInfos) &&
2709
2720
e1.equals(resType, that.resType)
2710
2721
}
2711
- case _ =>
2722
+ case _ =>
2712
2723
false
2713
2724
}
2714
2725
}
2715
2726
2716
- trait MethodOrPoly extends LambdaType with MethodicType // TODO: Make PolyTypes cached
2717
-
2718
2727
trait TermLambda extends LambdaType { thisLambdaType =>
2719
2728
import DepStatus ._
2720
2729
type ThisName = TermName
@@ -2830,7 +2839,7 @@ object Types {
2830
2839
abstract case class MethodType (paramNames : List [TermName ])(
2831
2840
paramInfosExp : MethodType => List [Type ],
2832
2841
resultTypeExp : MethodType => Type )
2833
- extends CachedGroundType with MethodOrPoly with TermLambda with NarrowCached { thisMethodType =>
2842
+ extends MethodOrPoly with TermLambda with NarrowCached { thisMethodType =>
2834
2843
import MethodType ._
2835
2844
2836
2845
type This = MethodType
@@ -2847,29 +2856,6 @@ object Types {
2847
2856
def computeSignature (implicit ctx : Context ): Signature =
2848
2857
resultSignature.prepend(paramInfos, isJavaMethod)
2849
2858
2850
- final override def computeHash (h : Hashing ) = h.doHash(getClass, paramNames, resType, paramInfos)
2851
-
2852
- final override def eql (that : Type ) = that match {
2853
- case that : MethodType =>
2854
- paramNames.eqElements(that.paramNames) &&
2855
- paramInfos.eqElements(that.paramInfos) &&
2856
- resType.eq(that.resType) &&
2857
- companion.eq(that.companion)
2858
- case _ =>
2859
- false
2860
- }
2861
-
2862
- final override def iso (that : Any , e : StructEquality ) = that match {
2863
- case that : MethodType =>
2864
- paramNames.eqElements(that.paramNames) &&
2865
- companion.eq(that.companion) && {
2866
- val e1 = e.withBinders(this , that)
2867
- e1.equals(paramInfos, that.paramInfos) &&
2868
- e1.equals(resType, that.resType)
2869
- }
2870
- case _ =>
2871
- false
2872
- }
2873
2859
2874
2860
protected def prefixString = " MethodType"
2875
2861
}
@@ -3028,7 +3014,7 @@ object Types {
3028
3014
*/
3029
3015
class PolyType (val paramNames : List [TypeName ])(
3030
3016
paramInfosExp : PolyType => List [TypeBounds ], resultTypeExp : PolyType => Type )
3031
- extends UncachedGroundType with MethodOrPoly with TypeLambda {
3017
+ extends MethodOrPoly with TypeLambda {
3032
3018
3033
3019
type This = PolyType
3034
3020
def companion = PolyType
@@ -3059,18 +3045,6 @@ object Types {
3059
3045
case _ => this
3060
3046
}
3061
3047
3062
- final override def iso (that : Any , e : StructEquality ) = that match { // TODO: Move up to MethodOrPoly
3063
- case that : PolyType =>
3064
- paramNames.eqElements(that.paramNames) &&
3065
- companion.eq(that.companion) && {
3066
- val e1 = e.withBinders(this , that)
3067
- e1.equals(paramInfos, that.paramInfos) &&
3068
- e1.equals(resType, that.resType)
3069
- }
3070
- case _ =>
3071
- false
3072
- }
3073
-
3074
3048
protected def prefixString = " PolyType"
3075
3049
}
3076
3050
0 commit comments