@@ -2219,7 +2219,7 @@ object Types {
2219
2219
2220
2220
def derivedAndType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
2221
2221
if ((tp1 eq this .tp1) && (tp2 eq this .tp2)) this
2222
- else AndType .make(tp1, tp2)
2222
+ else AndType .make(tp1, tp2, checkValid = true )
2223
2223
2224
2224
def derived_& (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
2225
2225
if ((tp1 eq this .tp1) && (tp2 eq this .tp2)) this
@@ -2234,21 +2234,26 @@ object Types {
2234
2234
final class CachedAndType (tp1 : Type , tp2 : Type ) extends AndType (tp1, tp2)
2235
2235
2236
2236
object AndType {
2237
- def apply (tp1 : Type , tp2 : Type )(implicit ctx : Context ) = {
2237
+ def apply (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndType = {
2238
2238
assert(tp1.isValueType && tp2.isValueType, i " $tp1 & $tp2 / " + s " $tp1 & $tp2" )
2239
2239
unchecked(tp1, tp2)
2240
2240
}
2241
- def unchecked (tp1 : Type , tp2 : Type )(implicit ctx : Context ) = {
2241
+
2242
+ def unchecked (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndType = {
2242
2243
assertUnerased()
2243
2244
unique(new CachedAndType (tp1, tp2))
2244
2245
}
2245
- def make (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
2246
+
2247
+ /** Make an AndType using `op` unless clearly unnecessary (i.e. without
2248
+ * going through `&`).
2249
+ */
2250
+ def make (tp1 : Type , tp2 : Type , checkValid : Boolean = false )(implicit ctx : Context ): Type =
2246
2251
if ((tp1 eq tp2) || (tp2 eq defn.AnyType ))
2247
2252
tp1
2248
2253
else if (tp1 eq defn.AnyType )
2249
2254
tp2
2250
2255
else
2251
- apply(tp1, tp2)
2256
+ if (checkValid) apply(tp1, tp2) else unchecked (tp1, tp2)
2252
2257
}
2253
2258
2254
2259
abstract case class OrType (tp1 : Type , tp2 : Type ) extends CachedGroundType with AndOrType {
@@ -2994,7 +2999,7 @@ object Types {
2994
2999
// ----- Skolem types -----------------------------------------------
2995
3000
2996
3001
/** A skolem type reference with underlying type `binder`. */
2997
- abstract case class SkolemType (info : Type ) extends UncachedProxyType with ValueType with SingletonType {
3002
+ case class SkolemType (info : Type ) extends UncachedProxyType with ValueType with SingletonType {
2998
3003
override def underlying (implicit ctx : Context ) = info
2999
3004
def derivedSkolemType (info : Type )(implicit ctx : Context ) =
3000
3005
if (info eq this .info) this else SkolemType (info)
@@ -3010,13 +3015,6 @@ object Types {
3010
3015
override def toString = s " Skolem( $hashCode) "
3011
3016
}
3012
3017
3013
- final class CachedSkolemType (info : Type ) extends SkolemType (info)
3014
-
3015
- object SkolemType {
3016
- def apply (info : Type )(implicit ctx : Context ) =
3017
- unique(new CachedSkolemType (info))
3018
- }
3019
-
3020
3018
// ------------ Type variables ----------------------------------------
3021
3019
3022
3020
/** In a TypeApply tree, a TypeVar is created for each argument type to be inferred.
0 commit comments