@@ -2955,6 +2955,16 @@ object Types {
29552955 extends LambdaTypeCompanion [TermName , Type , LT ] {
29562956 def toPInfo (tp : Type )(implicit ctx : Context ): Type = tp
29572957 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+ }
29582968 }
29592969
29602970 abstract class TypeLambdaCompanion [LT <: TypeLambda ]
@@ -2967,6 +2977,8 @@ object Types {
29672977 }
29682978
29692979 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)))
29702982
29712983 /** Produce method type from parameter symbols, with special mappings for repeated
29722984 * and inline parameters:
@@ -2987,19 +2999,6 @@ object Types {
29872999 tl => params.map(p => tl.integrate(params, paramInfo(p))),
29883000 tl => tl.integrate(params, resultType))
29893001 }
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- }
30033002 }
30043003
30053004 object MethodType extends MethodTypeCompanion {
@@ -3079,6 +3078,20 @@ object Types {
30793078 protected def prefixString = " HKTypeLambda"
30803079 }
30813080
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+
30823095 /** The type of a polymorphic method. It has the same form as HKTypeLambda,
30833096 * except it applies to terms and parameters do not have variances.
30843097 */
@@ -3155,6 +3168,14 @@ object Types {
31553168 }
31563169 }
31573170
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+
31583179 object PolyType extends TypeLambdaCompanion [PolyType ] {
31593180 def apply (paramNames : List [TypeName ])(
31603181 paramInfosExp : PolyType => List [TypeBounds ],
0 commit comments