@@ -2955,6 +2955,16 @@ object Types {
2955
2955
extends LambdaTypeCompanion [TermName , Type , LT ] {
2956
2956
def toPInfo (tp : Type )(implicit ctx : Context ): Type = tp
2957
2957
def syntheticParamName (n : Int ) = nme.syntheticParamName(n)
2958
+
2959
+ def checkValid (mt : TermLambda )(implicit ctx : Context ): mt.type = {
2960
+ if (Config .checkTermLambdas)
2961
+ for ((paramInfo, idx) <- mt.paramInfos.zipWithIndex)
2962
+ paramInfo.foreachPart {
2963
+ case TermParamRef (`mt`, j) => assert(j < idx, mt)
2964
+ case _ =>
2965
+ }
2966
+ mt
2967
+ }
2958
2968
}
2959
2969
2960
2970
abstract class TypeLambdaCompanion [LT <: TypeLambda ]
@@ -2967,6 +2977,8 @@ object Types {
2967
2977
}
2968
2978
2969
2979
abstract class MethodTypeCompanion extends TermLambdaCompanion [MethodType ] { self =>
2980
+ final def apply (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(implicit ctx : Context ): MethodType =
2981
+ checkValid(unique(new CachedMethodType (paramNames)(paramInfosExp, resultTypeExp, self)))
2970
2982
2971
2983
/** Produce method type from parameter symbols, with special mappings for repeated
2972
2984
* and inline parameters:
@@ -2987,19 +2999,6 @@ object Types {
2987
2999
tl => params.map(p => tl.integrate(params, paramInfo(p))),
2988
3000
tl => tl.integrate(params, resultType))
2989
3001
}
2990
-
2991
- final def apply (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(implicit ctx : Context ): MethodType =
2992
- checkValid(unique(new CachedMethodType (paramNames)(paramInfosExp, resultTypeExp, self)))
2993
-
2994
- def checkValid (mt : MethodType )(implicit ctx : Context ): mt.type = {
2995
- if (Config .checkMethodTypes)
2996
- for ((paramInfo, idx) <- mt.paramInfos.zipWithIndex)
2997
- paramInfo.foreachPart {
2998
- case TermParamRef (`mt`, j) => assert(j < idx, mt)
2999
- case _ =>
3000
- }
3001
- mt
3002
- }
3003
3002
}
3004
3003
3005
3004
object MethodType extends MethodTypeCompanion {
@@ -3079,6 +3078,20 @@ object Types {
3079
3078
protected def prefixString = " HKTypeLambda"
3080
3079
}
3081
3080
3081
+ class HKTermLambda (val paramNames : List [TermName ])(
3082
+ paramInfosExp : HKTermLambda => List [Type ], resultTypeExp : HKTermLambda => Type )
3083
+ extends HKLambda with TermLambda {
3084
+ type This = HKTermLambda
3085
+ def companion = HKTermLambda
3086
+
3087
+ val paramInfos : List [Type ] = paramInfosExp(this )
3088
+ val resType : Type = resultTypeExp(this )
3089
+
3090
+ assert(resType.isInstanceOf [TermType ], this )
3091
+
3092
+ protected def prefixString = " HKTermLambda"
3093
+ }
3094
+
3082
3095
/** The type of a polymorphic method. It has the same form as HKTypeLambda,
3083
3096
* except it applies to terms and parameters do not have variances.
3084
3097
*/
@@ -3155,6 +3168,14 @@ object Types {
3155
3168
}
3156
3169
}
3157
3170
3171
+ object HKTermLambda extends TermLambdaCompanion [HKTermLambda ] {
3172
+ def apply (paramNames : List [TermName ])(
3173
+ paramInfosExp : HKTermLambda => List [Type ],
3174
+ resultTypeExp : HKTermLambda => Type )(implicit ctx : Context ): HKTermLambda = {
3175
+ checkValid(unique(new HKTermLambda (paramNames)(paramInfosExp, resultTypeExp)))
3176
+ }
3177
+ }
3178
+
3158
3179
object PolyType extends TypeLambdaCompanion [PolyType ] {
3159
3180
def apply (paramNames : List [TypeName ])(
3160
3181
paramInfosExp : PolyType => List [TypeBounds ],
0 commit comments