From aa94474b1cdb95ef3952da678ea5fd58175d21f3 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 26 Apr 2021 18:10:48 +0200 Subject: [PATCH 1/3] Trial: bypass compiletimeConstantFold in translucentSuperType --- .../src/dotty/tools/dotc/core/Types.scala | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 8a0b0f12c167..a3345b939bd2 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4016,10 +4016,13 @@ object Types { } override def translucentSuperType(using Context): Type = tycon match { - case tycon: TypeRef if tycon.symbol.isOpaqueAlias => - tycon.translucentSuperType.applyIfParameterized(args) + case tycon: TypeRef => + if tycon.symbol.isOpaqueAlias then + tycon.translucentSuperType.applyIfParameterized(args) + else + tryMatchAlias(tycon).orElse(superType) case _ => - tryNormalize.orElse(superType) + superType } inline def map(inline op: Type => Type)(using Context) = @@ -4034,19 +4037,20 @@ object Types { case nil => x foldArgs(op(x, tycon), args) + private def tryMatchAlias(tycon: TypeRef)(using Context) = tycon.info match { + case MatchAlias(alias) => + trace(i"normalize $this", typr, show = true) { + MatchTypeTrace.recurseWith(this) { + alias.applyIfParameterized(args).tryNormalize + } + } + case _ => + NoType + } + override def tryNormalize(using Context): Type = tycon.stripTypeVar match { case tycon: TypeRef => - def tryMatchAlias = tycon.info match { - case MatchAlias(alias) => - trace(i"normalize $this", typr, show = true) { - MatchTypeTrace.recurseWith(this) { - alias.applyIfParameterized(args).tryNormalize - } - } - case _ => - NoType - } - tryCompiletimeConstantFold.orElse(tryMatchAlias) + tryCompiletimeConstantFold.orElse(tryMatchAlias(tycon)) case _ => NoType } From 68c95329e1ea031abe9fe45304a1260f1d18b17c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 27 Apr 2021 09:28:12 +0200 Subject: [PATCH 2/3] Revert "Trial: bypass compiletimeConstantFold in translucentSuperType" This reverts commit aa94474b1cdb95ef3952da678ea5fd58175d21f3. --- .../src/dotty/tools/dotc/core/Types.scala | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index a3345b939bd2..8a0b0f12c167 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4016,13 +4016,10 @@ object Types { } override def translucentSuperType(using Context): Type = tycon match { - case tycon: TypeRef => - if tycon.symbol.isOpaqueAlias then - tycon.translucentSuperType.applyIfParameterized(args) - else - tryMatchAlias(tycon).orElse(superType) + case tycon: TypeRef if tycon.symbol.isOpaqueAlias => + tycon.translucentSuperType.applyIfParameterized(args) case _ => - superType + tryNormalize.orElse(superType) } inline def map(inline op: Type => Type)(using Context) = @@ -4037,20 +4034,19 @@ object Types { case nil => x foldArgs(op(x, tycon), args) - private def tryMatchAlias(tycon: TypeRef)(using Context) = tycon.info match { - case MatchAlias(alias) => - trace(i"normalize $this", typr, show = true) { - MatchTypeTrace.recurseWith(this) { - alias.applyIfParameterized(args).tryNormalize - } - } - case _ => - NoType - } - override def tryNormalize(using Context): Type = tycon.stripTypeVar match { case tycon: TypeRef => - tryCompiletimeConstantFold.orElse(tryMatchAlias(tycon)) + def tryMatchAlias = tycon.info match { + case MatchAlias(alias) => + trace(i"normalize $this", typr, show = true) { + MatchTypeTrace.recurseWith(this) { + alias.applyIfParameterized(args).tryNormalize + } + } + case _ => + NoType + } + tryCompiletimeConstantFold.orElse(tryMatchAlias) case _ => NoType } From c0df023b46a0ad453c9938c6e4d9413c22dea938 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 27 Apr 2021 09:29:43 +0200 Subject: [PATCH 3/3] Revert translucentSuperType --- compiler/src/dotty/tools/dotc/core/Types.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 8a0b0f12c167..c4b42fa0889f 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4019,7 +4019,7 @@ object Types { case tycon: TypeRef if tycon.symbol.isOpaqueAlias => tycon.translucentSuperType.applyIfParameterized(args) case _ => - tryNormalize.orElse(superType) + superType } inline def map(inline op: Type => Type)(using Context) =