@@ -263,13 +263,15 @@ object Types {
263263
264264 /** Is this type exactly Nothing (no vars, aliases, refinements etc allowed)? */
265265 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 )
267268 case _ => false
268269 }
269270
270271 /** Is this type exactly Any (no vars, aliases, refinements etc allowed)? */
271272 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 )
273275 case _ => false
274276 }
275277
@@ -4647,7 +4649,13 @@ object Types {
46474649 object TypeBounds {
46484650 def apply (lo : Type , hi : Type )(using Context ): TypeBounds =
46494651 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
46514659 def emptyPolyKind (using Context ): TypeBounds = apply(defn.NothingType , defn.AnyKindType )
46524660 def upper (hi : Type )(using Context ): TypeBounds = apply(defn.NothingType , hi)
46534661 def lower (lo : Type )(using Context ): TypeBounds = apply(lo, defn.AnyType )
@@ -4790,7 +4798,15 @@ object Types {
47904798 final class CachedWildcardType (optBounds : Type ) extends WildcardType (optBounds)
47914799
47924800 @ 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))
47944810 }
47954811
47964812 /** An extractor for single abstract method types.
0 commit comments