@@ -263,13 +263,15 @@ object Types {
263
263
264
264
/** Is this type exactly Nothing (no vars, aliases, refinements etc allowed)? */
265
265
def isBottomType (using Context ): Boolean = this match {
266
- case tp : TypeRef => tp.symbol eq defn.NothingClass
266
+ case tp : TypeRef =>
267
+ tp.name == tpnme.Nothing && (tp.symbol eq defn.NothingClass )
267
268
case _ => false
268
269
}
269
270
270
271
/** Is this type exactly Any (no vars, aliases, refinements etc allowed)? */
271
272
def isTopType (using Context ): Boolean = this match {
272
- case tp : TypeRef => tp.symbol eq defn.AnyClass
273
+ case tp : TypeRef =>
274
+ tp.name == tpnme.Any && (tp.symbol eq defn.AnyClass )
273
275
case _ => false
274
276
}
275
277
@@ -4647,7 +4649,13 @@ object Types {
4647
4649
object TypeBounds {
4648
4650
def apply (lo : Type , hi : Type )(using Context ): TypeBounds =
4649
4651
unique(new RealTypeBounds (lo, hi))
4650
- def empty (using Context ): TypeBounds = apply(defn.NothingType , defn.AnyType )
4652
+ def empty (using Context ): TypeBounds =
4653
+ val result = ctx.base.emptyTypeBounds
4654
+ if result == null then
4655
+ ctx.base.emptyTypeBounds = apply(defn.NothingType , defn.AnyType )
4656
+ empty
4657
+ else
4658
+ result
4651
4659
def emptyPolyKind (using Context ): TypeBounds = apply(defn.NothingType , defn.AnyKindType )
4652
4660
def upper (hi : Type )(using Context ): TypeBounds = apply(defn.NothingType , hi)
4653
4661
def lower (lo : Type )(using Context ): TypeBounds = apply(lo, defn.AnyType )
@@ -4790,7 +4798,15 @@ object Types {
4790
4798
final class CachedWildcardType (optBounds : Type ) extends WildcardType (optBounds)
4791
4799
4792
4800
@ sharable object WildcardType extends WildcardType (NoType ) {
4793
- def apply (bounds : TypeBounds )(using Context ): WildcardType = unique(new CachedWildcardType (bounds))
4801
+ def apply (bounds : TypeBounds )(using Context ): WildcardType =
4802
+ if bounds eq TypeBounds .empty then
4803
+ val result = ctx.base.emptyWildcardBounds
4804
+ if result == null then
4805
+ ctx.base.emptyWildcardBounds = unique(CachedWildcardType (bounds))
4806
+ apply(bounds)
4807
+ else
4808
+ result
4809
+ else unique(CachedWildcardType (bounds))
4794
4810
}
4795
4811
4796
4812
/** An extractor for single abstract method types.
0 commit comments