@@ -3131,30 +3131,15 @@ object Types {
3131
3131
protected def prefixString = " PolyType"
3132
3132
}
3133
3133
3134
- object HKTypeLambda extends TypeLambdaCompanion [HKTypeLambda ] {
3135
- def apply (paramNames : List [TypeName ])(
3136
- paramInfosExp : HKTypeLambda => List [TypeBounds ],
3137
- resultTypeExp : HKTypeLambda => Type )(implicit ctx : Context ): HKTypeLambda = {
3138
- unique(new HKTypeLambda (paramNames)(paramInfosExp, resultTypeExp))
3139
- }
3140
-
3141
- def unapply (tl : HKTypeLambda ): Some [(List [LambdaParam ], Type )] =
3142
- Some ((tl.typeParams, tl.resType))
3143
-
3144
- def any (n : Int )(implicit ctx : Context ) =
3145
- apply(syntheticParamNames(n))(
3146
- pt => List .fill(n)(TypeBounds .empty), pt => defn.AnyType )
3147
-
3148
- override def paramName (param : ParamInfo .Of [TypeName ])(implicit ctx : Context ): TypeName =
3149
- param.paramName.withVariance(param.paramVariance)
3134
+ trait HKCompanion [N <: Name , PInfo <: Type , LT <: LambdaType ] extends LambdaTypeCompanion [N , PInfo , LT ] {
3150
3135
3151
3136
/** Distributes Lambda inside type bounds. Examples:
3152
3137
*
3153
3138
* type T[X] = U becomes type T = [X] -> U
3154
3139
* type T[X] <: U becomes type T >: Nothign <: ([X] -> U)
3155
3140
* type T[X] >: L <: U becomes type T >: ([X] -> L) <: ([X] -> U)
3156
3141
*/
3157
- override def fromParams [PI <: ParamInfo .Of [TypeName ]](params : List [PI ], resultType : Type )(implicit ctx : Context ): Type = {
3142
+ override def fromParams [PI <: ParamInfo .Of [N ]](params : List [PI ], resultType : Type )(implicit ctx : Context ): Type = {
3158
3143
def expand (tp : Type ) = super .fromParams(params, tp)
3159
3144
resultType match {
3160
3145
case rt : TypeAlias =>
@@ -3168,7 +3153,25 @@ object Types {
3168
3153
}
3169
3154
}
3170
3155
3171
- object HKTermLambda extends TermLambdaCompanion [HKTermLambda ] {
3156
+ object HKTypeLambda extends TypeLambdaCompanion [HKTypeLambda ] with HKCompanion [TypeName , TypeBounds , HKTypeLambda ] {
3157
+ def apply (paramNames : List [TypeName ])(
3158
+ paramInfosExp : HKTypeLambda => List [TypeBounds ],
3159
+ resultTypeExp : HKTypeLambda => Type )(implicit ctx : Context ): HKTypeLambda = {
3160
+ unique(new HKTypeLambda (paramNames)(paramInfosExp, resultTypeExp))
3161
+ }
3162
+
3163
+ def unapply (tl : HKTypeLambda ): Some [(List [LambdaParam ], Type )] =
3164
+ Some ((tl.typeParams, tl.resType))
3165
+
3166
+ def any (n : Int )(implicit ctx : Context ) =
3167
+ apply(syntheticParamNames(n))(
3168
+ pt => List .fill(n)(TypeBounds .empty), pt => defn.AnyType )
3169
+
3170
+ override def paramName (param : ParamInfo .Of [TypeName ])(implicit ctx : Context ): TypeName =
3171
+ param.paramName.withVariance(param.paramVariance)
3172
+ }
3173
+
3174
+ object HKTermLambda extends TermLambdaCompanion [HKTermLambda ] with HKCompanion [TermName , Type , HKTermLambda ] {
3172
3175
def apply (paramNames : List [TermName ])(
3173
3176
paramInfosExp : HKTermLambda => List [Type ],
3174
3177
resultTypeExp : HKTermLambda => Type )(implicit ctx : Context ): HKTermLambda = {
0 commit comments