@@ -3119,25 +3119,20 @@ object Types {
3119
3119
unique(new CachedClassInfo (prefix, cls, classParents, decls, selfInfo))
3120
3120
}
3121
3121
3122
- /** Type bounds >: lo <: hi
3123
- * @param bindingKind: If != NoBinding, it indicates that this is
3124
- * an introduction of a higher-kinded type parameter.
3125
- * In that case it also defines the variance of the parameter.
3126
- */
3127
- abstract case class TypeBounds (lo : Type , hi : Type )(val bindingKind : BindingKind ) extends CachedProxyType with TypeType {
3122
+ /** Type bounds >: lo <: hi */
3123
+ abstract case class TypeBounds (lo : Type , hi : Type ) extends CachedProxyType with TypeType {
3128
3124
3129
3125
assert(lo.isInstanceOf [TermType ])
3130
3126
assert(hi.isInstanceOf [TermType ])
3131
3127
3132
3128
def variance : Int = 0
3133
- def isBinding = bindingKind != NoBinding
3134
3129
3135
3130
override def underlying (implicit ctx : Context ): Type = hi
3136
3131
3137
3132
/** The non-alias type bounds type with given bounds */
3138
- def derivedTypeBounds (lo : Type , hi : Type , bk : BindingKind = this .bindingKind )(implicit ctx : Context ) =
3139
- if ((lo eq this .lo) && (hi eq this .hi) && (bk == this .bindingKind) && ( variance == 0 )) this
3140
- else TypeBounds (lo, hi, bk )
3133
+ def derivedTypeBounds (lo : Type , hi : Type )(implicit ctx : Context ) =
3134
+ if ((lo eq this .lo) && (hi eq this .hi) && (variance == 0 )) this
3135
+ else TypeBounds (lo, hi)
3141
3136
3142
3137
/** If this is an alias, a derived alias with the new variance,
3143
3138
* Otherwise the type itself.
@@ -3147,13 +3142,6 @@ object Types {
3147
3142
case _ => this
3148
3143
}
3149
3144
3150
- def withBindingKind (bk : BindingKind )(implicit ctx : Context ) = this match {
3151
- case tp : TypeAlias => assert(bk == NoBinding ); this
3152
- case _ => derivedTypeBounds(lo, hi, bk)
3153
- }
3154
-
3155
- // def checkBinding: this.type = { assert(isBinding); this }
3156
-
3157
3145
def contains (tp : Type )(implicit ctx : Context ): Boolean = tp match {
3158
3146
case tp : TypeBounds => lo <:< tp.lo && tp.hi <:< hi
3159
3147
case tp : ClassInfo =>
@@ -3166,12 +3154,12 @@ object Types {
3166
3154
def & (that : TypeBounds )(implicit ctx : Context ): TypeBounds =
3167
3155
if ((this .lo frozen_<:< that.lo) && (that.hi frozen_<:< this .hi)) that
3168
3156
else if ((that.lo frozen_<:< this .lo) && (this .hi frozen_<:< that.hi)) this
3169
- else TypeBounds (this .lo | that.lo, this .hi & that.hi, this .bindingKind join that.bindingKind )
3157
+ else TypeBounds (this .lo | that.lo, this .hi & that.hi)
3170
3158
3171
3159
def | (that : TypeBounds )(implicit ctx : Context ): TypeBounds =
3172
3160
if ((this .lo frozen_<:< that.lo) && (that.hi frozen_<:< this .hi)) this
3173
3161
else if ((that.lo frozen_<:< this .lo) && (this .hi frozen_<:< that.hi)) that
3174
- else TypeBounds (this .lo & that.lo, this .hi | that.hi, this .bindingKind join that.bindingKind )
3162
+ else TypeBounds (this .lo & that.lo, this .hi | that.hi)
3175
3163
3176
3164
override def & (that : Type )(implicit ctx : Context ) = that match {
3177
3165
case that : TypeBounds => this & that
@@ -3191,25 +3179,22 @@ object Types {
3191
3179
/** If this type and that type have the same variance, this variance, otherwise 0 */
3192
3180
final def commonVariance (that : TypeBounds ): Int = (this .variance + that.variance) / 2
3193
3181
3194
- override def computeHash = doHash(variance * 41 + bindingKind.n , lo, hi)
3182
+ override def computeHash = doHash(variance, lo, hi)
3195
3183
override def equals (that : Any ): Boolean = that match {
3196
3184
case that : TypeBounds =>
3197
3185
(this .lo eq that.lo) && (this .hi eq that.hi) &&
3198
- (this .variance == that.variance) && ( this .bindingKind == that.bindingKind)
3186
+ (this .variance == that.variance)
3199
3187
case _ =>
3200
3188
false
3201
3189
}
3202
3190
3203
- override def toString = {
3204
- def bkString = if (isBinding) s " |v= ${BindingKind .toVariance(bindingKind)}" else " "
3205
- if (lo eq hi) s " TypeAlias( $lo, $variance) "
3206
- else s " TypeBounds( $lo, $hi$bkString) "
3207
- }
3191
+ override def toString =
3192
+ if (lo eq hi) s " TypeAlias( $lo, $variance) " else s " TypeBounds( $lo, $hi) "
3208
3193
}
3209
3194
3210
- class RealTypeBounds (lo : Type , hi : Type , bk : BindingKind ) extends TypeBounds (lo, hi)(bk )
3195
+ class RealTypeBounds (lo : Type , hi : Type ) extends TypeBounds (lo, hi)
3211
3196
3212
- abstract class TypeAlias (val alias : Type , override val variance : Int ) extends TypeBounds (alias, alias)( NoBinding ) {
3197
+ abstract class TypeAlias (val alias : Type , override val variance : Int ) extends TypeBounds (alias, alias) {
3213
3198
/** pre: this is a type alias */
3214
3199
def derivedTypeAlias (alias : Type , variance : Int = this .variance)(implicit ctx : Context ) =
3215
3200
if ((alias eq this .alias) && (variance == this .variance)) this
@@ -3240,8 +3225,8 @@ object Types {
3240
3225
}
3241
3226
3242
3227
object TypeBounds {
3243
- def apply (lo : Type , hi : Type , bk : BindingKind = NoBinding )(implicit ctx : Context ): TypeBounds =
3244
- unique(new RealTypeBounds (lo, hi, bk ))
3228
+ def apply (lo : Type , hi : Type )(implicit ctx : Context ): TypeBounds =
3229
+ unique(new RealTypeBounds (lo, hi))
3245
3230
def empty (implicit ctx : Context ) = apply(defn.NothingType , defn.AnyType )
3246
3231
def upper (hi : Type )(implicit ctx : Context ) = apply(defn.NothingType , hi)
3247
3232
def lower (lo : Type )(implicit ctx : Context ) = apply(lo, defn.AnyType )
@@ -3253,31 +3238,6 @@ object Types {
3253
3238
def unapply (tp : TypeAlias ): Option [Type ] = Some (tp.alias)
3254
3239
}
3255
3240
3256
- /** A value class defining the interpretation of a TypeBounds
3257
- * as either a regular type bounds or a binding (i.e. introduction) of a
3258
- * higher-kinded type parameter.
3259
- * TODO: drop
3260
- */
3261
- class BindingKind (val n : Byte ) extends AnyVal {
3262
- def join (that : BindingKind ) =
3263
- if (this == that) this
3264
- else if (this == NoBinding || that == NoBinding ) NoBinding
3265
- else NonvariantBinding
3266
- }
3267
-
3268
- val NoBinding = new BindingKind (0 ) // Regular type bounds
3269
- val ContravariantBinding = new BindingKind (1 ) // Bounds for contravariant hk type param
3270
- val NonvariantBinding = new BindingKind (2 ) // Bounds for nonvariant hk type param
3271
- val CovariantBinding = new BindingKind (3 ) // Bounds for covariant hk type param
3272
-
3273
- object BindingKind {
3274
- def fromVariance (v : Int ): BindingKind = new BindingKind ((v + NonvariantBinding .n).toByte)
3275
- def toVariance (bk : BindingKind ): Int = {
3276
- assert(bk.n != 0 )
3277
- bk.n - NonvariantBinding .n
3278
- }
3279
- }
3280
-
3281
3241
// ----- Annotated and Import types -----------------------------------------------
3282
3242
3283
3243
/** An annotated type tpe @ annot */
0 commit comments