@@ -2626,7 +2626,7 @@ object Types {
2626
2626
def paramNames : List [ThisName ]
2627
2627
def paramInfos : List [PInfo ]
2628
2628
def resType : Type
2629
- def newParamRef (n : Int ): ParamRefType
2629
+ def newParamRef (n : Int )( implicit ctx : Context ) : ParamRefType
2630
2630
2631
2631
override def resultType (implicit ctx : Context ) = resType
2632
2632
@@ -2640,7 +2640,12 @@ object Types {
2640
2640
final def isTypeLambda = isInstanceOf [TypeLambda ]
2641
2641
final def isHigherKinded = isInstanceOf [TypeProxy ]
2642
2642
2643
- lazy val paramRefs : List [ParamRefType ] = paramNames.indices.toList.map(newParamRef)
2643
+ private var myParamRefs : List [ParamRefType ] = null
2644
+
2645
+ def paramRefs (implicit ctx : Context ): List [ParamRefType ] = {
2646
+ if (myParamRefs == null ) myParamRefs = paramNames.indices.toList.map(newParamRef)
2647
+ myParamRefs
2648
+ }
2644
2649
2645
2650
protected def computeSignature (implicit ctx : Context ) = resultSignature
2646
2651
@@ -2801,7 +2806,7 @@ object Types {
2801
2806
*/
2802
2807
def isParamDependent (implicit ctx : Context ): Boolean = paramDependencyStatus == TrueDeps
2803
2808
2804
- def newParamRef (n : Int ) = TermParamRef (this , n)
2809
+ def newParamRef (n : Int )( implicit ctx : Context ) = TermParamRef (this , n)
2805
2810
}
2806
2811
2807
2812
abstract case class MethodType (paramNames : List [TermName ])(
@@ -2956,7 +2961,7 @@ object Types {
2956
2961
def isDependent (implicit ctx : Context ): Boolean = true
2957
2962
def isParamDependent (implicit ctx : Context ): Boolean = true
2958
2963
2959
- def newParamRef (n : Int ) = TypeParamRef (this , n)
2964
+ def newParamRef (n : Int )( implicit ctx : Context ) = TypeParamRef (this , n)
2960
2965
2961
2966
lazy val typeParams : List [LambdaParam ] =
2962
2967
paramNames.indices.toList.map(new LambdaParam (this , _))
@@ -3114,7 +3119,7 @@ object Types {
3114
3119
def paramInfoAsSeenFrom (pre : Type )(implicit ctx : Context ) = paramInfo
3115
3120
def paramInfoOrCompleter (implicit ctx : Context ): Type = paramInfo
3116
3121
def paramVariance (implicit ctx : Context ): Int = tl.paramNames(n).variance
3117
- def toArg : Type = TypeParamRef (tl, n)
3122
+ def toArg ( implicit ctx : Context ) : Type = TypeParamRef (tl, n)
3118
3123
def paramRef (implicit ctx : Context ): Type = TypeParamRef (tl, n)
3119
3124
}
3120
3125
@@ -3328,7 +3333,7 @@ object Types {
3328
3333
abstract class BoundType extends CachedProxyType with ValueType {
3329
3334
type BT <: Type
3330
3335
val binder : BT
3331
- def copyBoundType (bt : BT ): Type
3336
+ def copyBoundType (bt : BT )( implicit ctx : Context ) : Type
3332
3337
}
3333
3338
3334
3339
abstract class ParamRef extends BoundType {
@@ -3357,14 +3362,21 @@ object Types {
3357
3362
}
3358
3363
}
3359
3364
3360
- case class TermParamRef (binder : TermLambda , paramNum : Int ) extends ParamRef {
3365
+ abstract case class TermParamRef (binder : TermLambda , paramNum : Int ) extends ParamRef {
3361
3366
type BT = TermLambda
3362
- def copyBoundType (bt : BT ) = TermParamRef (bt, paramNum)
3367
+ def copyBoundType (bt : BT )(implicit ctx : Context ) = TermParamRef (bt, paramNum)
3368
+ }
3369
+
3370
+ class CachedTermParamRef (binder : TermLambda , paramNum : Int ) extends TermParamRef (binder, paramNum)
3371
+
3372
+ object TermParamRef {
3373
+ def apply (binder : TermLambda , paramNum : Int )(implicit ctx : Context ) =
3374
+ unique(new CachedTermParamRef (binder, paramNum))
3363
3375
}
3364
3376
3365
- case class TypeParamRef (binder : TypeLambda , paramNum : Int ) extends ParamRef {
3377
+ abstract case class TypeParamRef (binder : TypeLambda , paramNum : Int ) extends ParamRef {
3366
3378
type BT = TypeLambda
3367
- def copyBoundType (bt : BT ) = TypeParamRef (bt, paramNum)
3379
+ def copyBoundType (bt : BT )( implicit ctx : Context ) = TypeParamRef (bt, paramNum)
3368
3380
3369
3381
/** Looking only at the structure of `bound`, is one of the following true?
3370
3382
* - fromBelow and param <:< bound
@@ -3380,11 +3392,21 @@ object Types {
3380
3392
}
3381
3393
}
3382
3394
3395
+ class ConcreteTypeParamRef (binder : TypeLambda , paramNum : Int ) extends TypeParamRef (binder, paramNum)
3396
+
3397
+ object TypeParamRef {
3398
+ def apply (binder : TypeLambda , paramNum : Int )(implicit ctx : Context ) =
3399
+ unique(new ConcreteTypeParamRef (binder, paramNum))
3400
+
3401
+ def uncached (binder : TypeLambda , paramNum : Int ) =
3402
+ new ConcreteTypeParamRef (binder : TypeLambda , paramNum : Int )
3403
+ }
3404
+
3383
3405
/** a self-reference to an enclosing recursive type. */
3384
3406
case class RecThis (binder : RecType ) extends BoundType with SingletonType {
3385
3407
type BT = RecType
3386
3408
override def underlying (implicit ctx : Context ) = binder
3387
- def copyBoundType (bt : BT ) = RecThis (bt)
3409
+ def copyBoundType (bt : BT )( implicit ctx : Context ) = RecThis (bt)
3388
3410
3389
3411
// need to customize hashCode and equals to prevent infinite recursion
3390
3412
// between RecTypes and RecRefs.
0 commit comments