@@ -1881,7 +1881,9 @@ object Types {
1881
1881
/** The closest supertype of this type. This is the same as `underlying`,
1882
1882
* except that
1883
1883
* - instead of a TyperBounds type it returns its upper bound, and
1884
- * - for applied types it returns the upper bound of the constructor re-applied to the arguments.
1884
+ * - for applied types it returns
1885
+ * * if the applied type can be matchtype-reduced, the redux
1886
+ * * otherwise, the upper bound of the constructor re-applied to the arguments.
1885
1887
*/
1886
1888
def superType (using Context ): Type = underlying match {
1887
1889
case TypeBounds (_, hi) => hi
@@ -3996,12 +3998,15 @@ object Types {
3996
3998
3997
3999
override def superType (using Context ): Type = {
3998
4000
if (ctx.period != validSuper) {
3999
- cachedSuper = tycon match {
4000
- case tycon : HKTypeLambda => defn.AnyType
4001
- case tycon : TypeRef if tycon.symbol.isClass => tycon
4002
- case tycon : TypeProxy => tycon.superType.applyIfParameterized(args)
4003
- case _ => defn.AnyType
4004
- }
4001
+ cachedSuper = tycon match
4002
+ case tycon : HKTypeLambda =>
4003
+ defn.AnyType
4004
+ case tycon : TypeRef if tycon.symbol.isClass =>
4005
+ tycon
4006
+ case tycon : TypeProxy =>
4007
+ tryNormalize.orElse(tycon.superType.applyIfParameterized(args))
4008
+ case _ =>
4009
+ defn.AnyType
4005
4010
validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4006
4011
}
4007
4012
cachedSuper
@@ -4011,7 +4016,7 @@ object Types {
4011
4016
case tycon : TypeRef if tycon.symbol.isOpaqueAlias =>
4012
4017
tycon.translucentSuperType.applyIfParameterized(args)
4013
4018
case _ =>
4014
- tryNormalize.orElse( superType)
4019
+ superType
4015
4020
}
4016
4021
4017
4022
inline def map (inline op : Type => Type )(using Context ) =
0 commit comments