@@ -2634,7 +2634,7 @@ object Types {
2634
2634
def paramNames : List [ThisName ]
2635
2635
def paramInfos : List [PInfo ]
2636
2636
def resType : Type
2637
- def newParamRef (n : Int ): ParamRefType
2637
+ def newParamRef (n : Int )( implicit ctx : Context ) : ParamRefType
2638
2638
2639
2639
override def resultType (implicit ctx : Context ) = resType
2640
2640
@@ -2648,7 +2648,12 @@ object Types {
2648
2648
final def isTypeLambda = isInstanceOf [TypeLambda ]
2649
2649
final def isHigherKinded = isInstanceOf [TypeProxy ]
2650
2650
2651
- lazy val paramRefs : List [ParamRefType ] = paramNames.indices.toList.map(newParamRef)
2651
+ private var myParamRefs : List [ParamRefType ] = null
2652
+
2653
+ def paramRefs (implicit ctx : Context ): List [ParamRefType ] = {
2654
+ if (myParamRefs == null ) myParamRefs = paramNames.indices.toList.map(newParamRef)
2655
+ myParamRefs
2656
+ }
2652
2657
2653
2658
protected def computeSignature (implicit ctx : Context ) = resultSignature
2654
2659
@@ -2809,7 +2814,7 @@ object Types {
2809
2814
*/
2810
2815
def isParamDependent (implicit ctx : Context ): Boolean = paramDependencyStatus == TrueDeps
2811
2816
2812
- def newParamRef (n : Int ) = TermParamRef (this , n)
2817
+ def newParamRef (n : Int )( implicit ctx : Context ) = TermParamRef (this , n)
2813
2818
}
2814
2819
2815
2820
abstract case class MethodType (paramNames : List [TermName ])(
@@ -2964,7 +2969,7 @@ object Types {
2964
2969
def isDependent (implicit ctx : Context ): Boolean = true
2965
2970
def isParamDependent (implicit ctx : Context ): Boolean = true
2966
2971
2967
- def newParamRef (n : Int ) = TypeParamRef (this , n)
2972
+ def newParamRef (n : Int )( implicit ctx : Context ) = TypeParamRef (this , n)
2968
2973
2969
2974
lazy val typeParams : List [LambdaParam ] =
2970
2975
paramNames.indices.toList.map(new LambdaParam (this , _))
@@ -3122,7 +3127,7 @@ object Types {
3122
3127
def paramInfoAsSeenFrom (pre : Type )(implicit ctx : Context ) = paramInfo
3123
3128
def paramInfoOrCompleter (implicit ctx : Context ): Type = paramInfo
3124
3129
def paramVariance (implicit ctx : Context ): Int = tl.paramNames(n).variance
3125
- def toArg : Type = TypeParamRef (tl, n)
3130
+ def toArg ( implicit ctx : Context ) : Type = TypeParamRef (tl, n)
3126
3131
def paramRef (implicit ctx : Context ): Type = TypeParamRef (tl, n)
3127
3132
}
3128
3133
@@ -3336,7 +3341,7 @@ object Types {
3336
3341
abstract class BoundType extends CachedProxyType with ValueType {
3337
3342
type BT <: Type
3338
3343
val binder : BT
3339
- def copyBoundType (bt : BT ): Type
3344
+ def copyBoundType (bt : BT )( implicit ctx : Context ) : Type
3340
3345
}
3341
3346
3342
3347
abstract class ParamRef extends BoundType {
@@ -3365,14 +3370,21 @@ object Types {
3365
3370
}
3366
3371
}
3367
3372
3368
- case class TermParamRef (binder : TermLambda , paramNum : Int ) extends ParamRef {
3373
+ abstract case class TermParamRef (binder : TermLambda , paramNum : Int ) extends ParamRef {
3369
3374
type BT = TermLambda
3370
- def copyBoundType (bt : BT ) = TermParamRef (bt, paramNum)
3375
+ def copyBoundType (bt : BT )(implicit ctx : Context ) = TermParamRef (bt, paramNum)
3376
+ }
3377
+
3378
+ class CachedTermParamRef (binder : TermLambda , paramNum : Int ) extends TermParamRef (binder, paramNum)
3379
+
3380
+ object TermParamRef {
3381
+ def apply (binder : TermLambda , paramNum : Int )(implicit ctx : Context ) =
3382
+ unique(new CachedTermParamRef (binder, paramNum))
3371
3383
}
3372
3384
3373
- case class TypeParamRef (binder : TypeLambda , paramNum : Int ) extends ParamRef {
3385
+ abstract case class TypeParamRef (binder : TypeLambda , paramNum : Int ) extends ParamRef {
3374
3386
type BT = TypeLambda
3375
- def copyBoundType (bt : BT ) = TypeParamRef (bt, paramNum)
3387
+ def copyBoundType (bt : BT )( implicit ctx : Context ) = TypeParamRef (bt, paramNum)
3376
3388
3377
3389
/** Looking only at the structure of `bound`, is one of the following true?
3378
3390
* - fromBelow and param <:< bound
@@ -3388,11 +3400,21 @@ object Types {
3388
3400
}
3389
3401
}
3390
3402
3403
+ class ConcreteTypeParamRef (binder : TypeLambda , paramNum : Int ) extends TypeParamRef (binder, paramNum)
3404
+
3405
+ object TypeParamRef {
3406
+ def apply (binder : TypeLambda , paramNum : Int )(implicit ctx : Context ) =
3407
+ unique(new ConcreteTypeParamRef (binder, paramNum))
3408
+
3409
+ def uncached (binder : TypeLambda , paramNum : Int ) =
3410
+ new ConcreteTypeParamRef (binder : TypeLambda , paramNum : Int )
3411
+ }
3412
+
3391
3413
/** a self-reference to an enclosing recursive type. */
3392
3414
case class RecThis (binder : RecType ) extends BoundType with SingletonType {
3393
3415
type BT = RecType
3394
3416
override def underlying (implicit ctx : Context ) = binder
3395
- def copyBoundType (bt : BT ) = RecThis (bt)
3417
+ def copyBoundType (bt : BT )( implicit ctx : Context ) = RecThis (bt)
3396
3418
3397
3419
// need to customize hashCode and equals to prevent infinite recursion
3398
3420
// between RecTypes and RecRefs.
0 commit comments