From 65748a809405c9ded9c0e495f8b3e9f7f221e5d0 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Fri, 12 Apr 2024 00:20:47 +0200 Subject: [PATCH 01/10] Drop normalization of applied match alias arguments Delay their normalization until it is needed. Avoids overflows from infinite match types that did not need to normalize. Also improves MatchTypeTraces as a side effect. It appears to have been added to avoid some separate issue, which seems to have been fixed. It is no longer needed since the previous fix with constant folding in disjointnessBoundary. [Cherry-picked 32752e28e898473a9f78f1ca8a8a019decd3f665] --- compiler/src/dotty/tools/dotc/core/Types.scala | 2 +- tests/neg/i12049d.check | 14 ++++++++++++++ tests/neg/i12049d.scala | 14 ++++++++++++++ tests/pos/matchtype-unusedArg/A_1.scala | 8 ++++++++ tests/pos/matchtype-unusedArg/B_2.scala | 2 ++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i12049d.check create mode 100644 tests/neg/i12049d.scala create mode 100644 tests/pos/matchtype-unusedArg/A_1.scala create mode 100644 tests/pos/matchtype-unusedArg/B_2.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index efb353c4050c..681ec7a90df1 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4695,7 +4695,7 @@ object Types extends TypeUtils { case AliasingBounds(alias) if isMatchAlias => trace(i"normalize $this", typr, show = true) { MatchTypeTrace.recurseWith(this) { - alias.applyIfParameterized(args.map(_.normalized)).tryNormalize + alias.applyIfParameterized(args).tryNormalize /* `applyIfParameterized` may reduce several HKTypeLambda applications * before the underlying MatchType is reached. * Even if they do not involve any match type normalizations yet, diff --git a/tests/neg/i12049d.check b/tests/neg/i12049d.check new file mode 100644 index 000000000000..fdb13aae4e43 --- /dev/null +++ b/tests/neg/i12049d.check @@ -0,0 +1,14 @@ +-- [E007] Type Mismatch Error: tests/neg/i12049d.scala:14:52 ----------------------------------------------------------- +14 |val x: M[NotRelevant[Nothing], Relevant[Nothing]] = 2 // error + | ^ + | Found: (2 : Int) + | Required: M[NotRelevant[Nothing], Relevant[Nothing]] + | + | Note: a match type could not be fully reduced: + | + | trying to reduce M[NotRelevant[Nothing], Relevant[Nothing]] + | trying to reduce Relevant[Nothing] + | failed since selector Nothing + | is uninhabited (there are no values of that type). + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i12049d.scala b/tests/neg/i12049d.scala new file mode 100644 index 000000000000..0011ec1f00b1 --- /dev/null +++ b/tests/neg/i12049d.scala @@ -0,0 +1,14 @@ + +trait A +trait B + +type M[X, Y] = Y match + case A => Int + case B => String + +type Relevant[Z] = Z match + case A => B +type NotRelevant[Z] = Z match + case B => A + +val x: M[NotRelevant[Nothing], Relevant[Nothing]] = 2 // error diff --git a/tests/pos/matchtype-unusedArg/A_1.scala b/tests/pos/matchtype-unusedArg/A_1.scala new file mode 100644 index 000000000000..4364a812f12c --- /dev/null +++ b/tests/pos/matchtype-unusedArg/A_1.scala @@ -0,0 +1,8 @@ + +type Rec[X] = X match + case Int => Rec[X] + +type M[Unused, Y] = Y match + case String => Double + +def foo[X](d: M[Rec[X], "hi"]) = ??? diff --git a/tests/pos/matchtype-unusedArg/B_2.scala b/tests/pos/matchtype-unusedArg/B_2.scala new file mode 100644 index 000000000000..437e53a1691d --- /dev/null +++ b/tests/pos/matchtype-unusedArg/B_2.scala @@ -0,0 +1,2 @@ + +def Test = foo[Int](3d) // crash before changes From 47d687bbab0f7973f822dcfb0928465e5b5ad9d1 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Wed, 24 Apr 2024 17:22:08 +0200 Subject: [PATCH 02/10] Use cached underlyingMatchType when normalizing applied match aliases Also fixes underlyingMatchType to not use the resType of HKTypeLambdas It should only be in `isMatch` used for `AliasingBounds`, not `isMatchAlias` [Cherry-picked ac980239a55d496f9c35f74e0dd6cc9879d1bb01] --- .../src/dotty/tools/dotc/core/Types.scala | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 681ec7a90df1..ce52d27412f2 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -492,12 +492,10 @@ object Types extends TypeUtils { /** Does this application expand to a match type? */ def isMatchAlias(using Context): Boolean = underlyingMatchType.exists - def underlyingMatchType(using Context): Type = stripped match { + def underlyingMatchType(using Context): Type = stripped match case tp: MatchType => tp - case tp: HKTypeLambda => tp.resType.underlyingMatchType case tp: AppliedType => tp.underlyingMatchType case _ => NoType - } /** Is this a higher-kinded type lambda with given parameter variances? * These lambdas are used as the RHS of higher-kinded abstract types or @@ -4682,6 +4680,7 @@ object Types extends TypeUtils { /** Exists if the tycon is a TypeRef of an alias with an underlying match type. * Anything else should have already been reduced in `appliedTo` by the TypeAssigner. + * May reduce several HKTypeLambda applications before the underlying MatchType is reached. */ override def underlyingMatchType(using Context): Type = if ctx.period != validUnderlyingMatch then @@ -4689,28 +4688,15 @@ object Types extends TypeUtils { validUnderlyingMatch = validSuper cachedUnderlyingMatch - override def tryNormalize(using Context): Type = tycon.stripTypeVar match { - case tycon: TypeRef => - def tryMatchAlias = tycon.info match - case AliasingBounds(alias) if isMatchAlias => - trace(i"normalize $this", typr, show = true) { - MatchTypeTrace.recurseWith(this) { - alias.applyIfParameterized(args).tryNormalize - /* `applyIfParameterized` may reduce several HKTypeLambda applications - * before the underlying MatchType is reached. - * Even if they do not involve any match type normalizations yet, - * we still want to record these reductions in the MatchTypeTrace. - * They should however only be attempted if they eventually expand - * to a match type, which is ensured by the `isMatchAlias` guard. - */ - } - } - case _ => - NoType - tryCompiletimeConstantFold.orElse(tryMatchAlias) - case _ => - NoType - } + override def tryNormalize(using Context): Type = + def tryMatchAlias = + if isMatchAlias then trace(i"normalize $this", typr, show = true): + if MatchTypeTrace.isRecording then + MatchTypeTrace.recurseWith(this)(superType.tryNormalize) + else + underlyingMatchType.tryNormalize + else NoType + tryCompiletimeConstantFold.orElse(tryMatchAlias) /** Is this an unreducible application to wildcard arguments? * This is the case if tycon is higher-kinded. This means From 6964304210d4f4dbd1bfde8350a9d5c6737e3586 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Tue, 30 Apr 2024 13:27:58 +0200 Subject: [PATCH 03/10] Cache underlying applied compiletime.ops [Cherry-picked 68ca883017888203a59341f7bd0e1d9c69b45e3a] --- .../src/dotty/tools/dotc/core/Types.scala | 28 +++++++++++-------- .../src/dotty/tools/dotc/typer/Typer.scala | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index ce52d27412f2..3ee1e79f5777 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -490,11 +490,11 @@ object Types extends TypeUtils { case _ => false /** Does this application expand to a match type? */ - def isMatchAlias(using Context): Boolean = underlyingMatchType.exists + def isMatchAlias(using Context): Boolean = underlyingNormalizable.isMatch - def underlyingMatchType(using Context): Type = stripped match + def underlyingNormalizable(using Context): Type = stripped match case tp: MatchType => tp - case tp: AppliedType => tp.underlyingMatchType + case tp: AppliedType => tp.underlyingNormalizable case _ => NoType /** Is this a higher-kinded type lambda with given parameter variances? @@ -4613,8 +4613,8 @@ object Types extends TypeUtils { private var myEvalRunId: RunId = NoRunId private var myEvalued: Type = uninitialized - private var validUnderlyingMatch: Period = Nowhere - private var cachedUnderlyingMatch: Type = uninitialized + private var validUnderlyingNormalizable: Period = Nowhere + private var cachedUnderlyingNormalizable: Type = uninitialized def isGround(acc: TypeAccumulator[Boolean])(using Context): Boolean = if myGround == 0 then myGround = if acc.foldOver(true, this) then 1 else -1 @@ -4682,11 +4682,15 @@ object Types extends TypeUtils { * Anything else should have already been reduced in `appliedTo` by the TypeAssigner. * May reduce several HKTypeLambda applications before the underlying MatchType is reached. */ - override def underlyingMatchType(using Context): Type = - if ctx.period != validUnderlyingMatch then - cachedUnderlyingMatch = superType.underlyingMatchType - validUnderlyingMatch = validSuper - cachedUnderlyingMatch + override def underlyingNormalizable(using Context): Type = + if ctx.period != validUnderlyingNormalizable then tycon match + case tycon: TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) => + cachedUnderlyingNormalizable = this + validUnderlyingNormalizable = ctx.period + case _ => + cachedUnderlyingNormalizable = superType.underlyingNormalizable + validUnderlyingNormalizable = validSuper + cachedUnderlyingNormalizable override def tryNormalize(using Context): Type = def tryMatchAlias = @@ -4694,7 +4698,7 @@ object Types extends TypeUtils { if MatchTypeTrace.isRecording then MatchTypeTrace.recurseWith(this)(superType.tryNormalize) else - underlyingMatchType.tryNormalize + underlyingNormalizable.tryNormalize else NoType tryCompiletimeConstantFold.orElse(tryMatchAlias) @@ -5268,7 +5272,7 @@ object Types extends TypeUtils { def apply(bound: Type, scrutinee: Type, cases: List[Type])(using Context): MatchType = unique(new CachedMatchType(bound, scrutinee, cases)) - def thatReducesUsingGadt(tp: Type)(using Context): Boolean = tp.underlyingMatchType match + def thatReducesUsingGadt(tp: Type)(using Context): Boolean = tp.underlyingNormalizable match case mt: MatchType => mt.reducesUsingGadt case _ => false diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 072527ce7fce..069ce4f1af00 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2031,7 +2031,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer case _ => false } - val result = pt.underlyingMatchType match { + val result = pt.underlyingNormalizable match { case mt: MatchType if isMatchTypeShaped(mt) => typedDependentMatchFinish(tree, sel1, selType, tree.cases, mt) case _ => From 74451b7b49a287f1cdec4b63d912cca500895192 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Tue, 30 Apr 2024 13:44:54 +0200 Subject: [PATCH 04/10] Use `underlyingNormalizable` in `Type#tryNormalize` [Cherry-picked a6cadec56e92412b2866895f6fbfc6149193f32b] --- .../src/dotty/tools/dotc/core/Types.scala | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 3ee1e79f5777..0c748d1dd189 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1556,11 +1556,13 @@ object Types extends TypeUtils { if (normed.exists) normed else this } - /** If this type can be normalized at the top-level by rewriting match types - * of S[n] types, the result after applying all toplevel normalizations, - * otherwise NoType + /** If this type has an underlying match type or applied compiletime.ops, + * then the result after applying all toplevel normalizations, otherwise NoType. */ - def tryNormalize(using Context): Type = NoType + def tryNormalize(using Context): Type = underlyingNormalizable match + case mt: MatchType => mt.tryNormalize + case tp: AppliedType => tp.tryCompiletimeConstantFold + case _ => NoType private def widenDealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = { val res = this.widen.dealias1(keep, keepOpaques = false) @@ -4693,14 +4695,9 @@ object Types extends TypeUtils { cachedUnderlyingNormalizable override def tryNormalize(using Context): Type = - def tryMatchAlias = - if isMatchAlias then trace(i"normalize $this", typr, show = true): - if MatchTypeTrace.isRecording then - MatchTypeTrace.recurseWith(this)(superType.tryNormalize) - else - underlyingNormalizable.tryNormalize - else NoType - tryCompiletimeConstantFold.orElse(tryMatchAlias) + if isMatchAlias && MatchTypeTrace.isRecording then + MatchTypeTrace.recurseWith(this)(superType.tryNormalize) + else super.tryNormalize /** Is this an unreducible application to wildcard arguments? * This is the case if tycon is higher-kinded. This means From 40dbcc261f68ed6d0649a56ab20118a6ff5fcbd9 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Tue, 30 Apr 2024 13:45:54 +0200 Subject: [PATCH 05/10] `stripLazyRef` for `underlyingNormalizable` [Cherry-picked 4fbba66ec6376e2d7f4f936cf79738fa86a49f23] --- compiler/src/dotty/tools/dotc/core/Types.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 0c748d1dd189..a1fe0be9e466 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -492,7 +492,7 @@ object Types extends TypeUtils { /** Does this application expand to a match type? */ def isMatchAlias(using Context): Boolean = underlyingNormalizable.isMatch - def underlyingNormalizable(using Context): Type = stripped match + def underlyingNormalizable(using Context): Type = stripped.stripLazyRef match case tp: MatchType => tp case tp: AppliedType => tp.underlyingNormalizable case _ => NoType @@ -3258,8 +3258,6 @@ object Types extends TypeUtils { private var myRef: Type | Null = null private var computed = false - override def tryNormalize(using Context): Type = ref.tryNormalize - def ref(using Context): Type = if computed then if myRef == null then From 0b6900e637a2838f73abc10ed20bd94ad24316eb Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Tue, 30 Apr 2024 13:57:30 +0200 Subject: [PATCH 06/10] Drop `handleRecursive` from `MatchType#tryNormalize` There is already a `handleRecursive` in `reduced` Having the two makes error messages undeterministic, see #20269 [Cherry-picked 309b1cfceeb812c589f932e16dbd50b09c11a5f4] --- compiler/src/dotty/tools/dotc/core/Types.scala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index a1fe0be9e466..b2c95035e886 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -5159,11 +5159,7 @@ object Types extends TypeUtils { private var reductionContext: util.MutableMap[Type, Type] | Null = null override def tryNormalize(using Context): Type = - try - reduced.normalized - catch - case ex: Throwable => - handleRecursive("normalizing", s"${scrutinee.show} match ..." , ex) + reduced.normalized private def thisMatchType = this From e9df00aac8d18612e610863dddf418b84c068b16 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Tue, 30 Apr 2024 14:01:32 +0200 Subject: [PATCH 07/10] Regroup `tryNormalize` logic [Cherry-picked 0b87d7fcdb40808226bf79857fe06246f2840e7a] --- .../src/dotty/tools/dotc/core/Types.scala | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index b2c95035e886..7a8581c3eb25 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -492,11 +492,6 @@ object Types extends TypeUtils { /** Does this application expand to a match type? */ def isMatchAlias(using Context): Boolean = underlyingNormalizable.isMatch - def underlyingNormalizable(using Context): Type = stripped.stripLazyRef match - case tp: MatchType => tp - case tp: AppliedType => tp.underlyingNormalizable - case _ => NoType - /** Is this a higher-kinded type lambda with given parameter variances? * These lambdas are used as the RHS of higher-kinded abstract types or * type aliases. The variance info is strictly needed only for abstract types. @@ -1548,22 +1543,25 @@ object Types extends TypeUtils { } deskolemizer(this) - /** The result of normalization using `tryNormalize`, or the type itself if - * tryNormlize yields NoType - */ - final def normalized(using Context): Type = { - val normed = tryNormalize - if (normed.exists) normed else this - } + /** The result of normalization, or the type itself if none apply. */ + final def normalized(using Context): Type = tryNormalize.orElse(this) /** If this type has an underlying match type or applied compiletime.ops, * then the result after applying all toplevel normalizations, otherwise NoType. */ def tryNormalize(using Context): Type = underlyingNormalizable match - case mt: MatchType => mt.tryNormalize + case mt: MatchType => mt.reduced.normalized case tp: AppliedType => tp.tryCompiletimeConstantFold case _ => NoType + /** Perform successive strippings, and beta-reductions of applied types until + * a match type or applied compiletime.ops is reached, if any, otherwise NoType. + */ + def underlyingNormalizable(using Context): Type = stripped.stripLazyRef match + case tp: MatchType => tp + case tp: AppliedType => tp.underlyingNormalizable + case _ => NoType + private def widenDealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = { val res = this.widen.dealias1(keep, keepOpaques = false) if (res eq this) res else res.widenDealias1(keep) @@ -4678,9 +4676,10 @@ object Types extends TypeUtils { case nil => x foldArgs(op(x, tycon), args) - /** Exists if the tycon is a TypeRef of an alias with an underlying match type. - * Anything else should have already been reduced in `appliedTo` by the TypeAssigner. - * May reduce several HKTypeLambda applications before the underlying MatchType is reached. + /** Exists if the tycon is a TypeRef of an alias with an underlying match type, + * or a compiletime applied type. Anything else should have already been + * reduced in `appliedTo` by the TypeAssigner. This may reduce several + * HKTypeLambda applications before the underlying normalizable type is reached. */ override def underlyingNormalizable(using Context): Type = if ctx.period != validUnderlyingNormalizable then tycon match @@ -5158,9 +5157,6 @@ object Types extends TypeUtils { private var myReduced: Type | Null = null private var reductionContext: util.MutableMap[Type, Type] | Null = null - override def tryNormalize(using Context): Type = - reduced.normalized - private def thisMatchType = this def reduced(using Context): Type = atPhaseNoLater(elimOpaquePhase) { From 216f4d1e25088d60049a8d38a901caf97d70e81d Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Wed, 1 May 2024 10:25:36 +0200 Subject: [PATCH 08/10] Add i974.scala to neg-best-effort-pickling.blacklist [Cherry-picked 9df3942d63513acd28bc5fcbe87c29e879c9d1fd] --- compiler/test/dotc/neg-best-effort-pickling.blacklist | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/test/dotc/neg-best-effort-pickling.blacklist b/compiler/test/dotc/neg-best-effort-pickling.blacklist index 2daf32509ed1..a582f085dd30 100644 --- a/compiler/test/dotc/neg-best-effort-pickling.blacklist +++ b/compiler/test/dotc/neg-best-effort-pickling.blacklist @@ -15,6 +15,7 @@ illegal-match-types.scala i13780-1.scala i20317a.scala i11226.scala +i974.scala # semantic db generation fails in the first compilation i1642.scala From 337d03ae3d0b67edb2907af2e5fb8bc315d846f0 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Mon, 3 Jun 2024 16:51:07 +0200 Subject: [PATCH 09/10] Add test for #20482 tryNormalize used to not recursively check if tycon of applied type was normalizable, this may be necessary in the case of an applied type dealiasing to a type lambda. Fixes #20482 [Cherry-picked 9465d65e185236353811e3cada62b91df61a1076] --- tests/pos/i20482.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/pos/i20482.scala diff --git a/tests/pos/i20482.scala b/tests/pos/i20482.scala new file mode 100644 index 000000000000..2a7680df054d --- /dev/null +++ b/tests/pos/i20482.scala @@ -0,0 +1,16 @@ +trait WrapperType[A] + +case class Foo[A]() + +case class Bar[A]() + +type FooToBar[D[_]] = [A] =>> D[Unit] match { + case Foo[Unit] => Bar[A] +} + +case class Test() +object Test { + implicit val wrapperType: WrapperType[Bar[Test]] = new WrapperType[Bar[Test]] {} +} + +val test = summon[WrapperType[FooToBar[Foo][Test]]] From a1a7b123ac88239a7fbd958d332ddfb5b8050bd5 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Wed, 12 Jun 2024 10:18:56 +0200 Subject: [PATCH 10/10] Fix `AliasingBounds#derivedAlias` an omission from ef7db7ad [Cherry-picked 1bfa8191f838b67768e2a44187f3128def83d146] --- compiler/src/dotty/tools/dotc/core/Types.scala | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 7a8581c3eb25..e6aee11b3d97 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -5708,7 +5708,8 @@ object Types extends TypeUtils { /** Common supertype of `TypeAlias` and `MatchAlias` */ abstract class AliasingBounds(val alias: Type) extends TypeBounds(alias, alias) { - def derivedAlias(alias: Type)(using Context): AliasingBounds + def derivedAlias(alias: Type)(using Context): AliasingBounds = + if alias eq this.alias then this else AliasingBounds(alias) override def computeHash(bs: Binders): Int = doHash(bs, alias) override def hashIsStable: Boolean = alias.hashIsStable @@ -5730,10 +5731,7 @@ object Types extends TypeUtils { /** = T */ - class TypeAlias(alias: Type) extends AliasingBounds(alias) { - def derivedAlias(alias: Type)(using Context): AliasingBounds = - if (alias eq this.alias) this else TypeAlias(alias) - } + class TypeAlias(alias: Type) extends AliasingBounds(alias) /** = T where `T` is a `MatchType` * @@ -5742,10 +5740,7 @@ object Types extends TypeUtils { * If we assumed full substitutivity, we would have to reject all recursive match * aliases (or else take the jump and allow full recursive types). */ - class MatchAlias(alias: Type) extends AliasingBounds(alias) { - def derivedAlias(alias: Type)(using Context): AliasingBounds = - if (alias eq this.alias) this else MatchAlias(alias) - } + class MatchAlias(alias: Type) extends AliasingBounds(alias) object TypeBounds { def apply(lo: Type, hi: Type)(using Context): TypeBounds =