From d2b64f2ac2793bdeb05423f5d8962524f8ffa826 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Wed, 4 Aug 2021 17:26:06 +0200 Subject: [PATCH] Fix #10867: Normalize after applyIfParameterized in superType --- .../src/dotty/tools/dotc/core/Types.scala | 2 +- tests/pos/10867.scala | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/pos/10867.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index a187dd260112..496e9df8f62a 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4114,7 +4114,7 @@ object Types { cachedSuper = tycon match { case tycon: HKTypeLambda => defn.AnyType case tycon: TypeRef if tycon.symbol.isClass => tycon - case tycon: TypeProxy => tycon.superType.applyIfParameterized(args) + case tycon: TypeProxy => tycon.superType.applyIfParameterized(args).normalized case _ => defn.AnyType } validSuper = if (tycon.isProvisional) Nowhere else ctx.period diff --git a/tests/pos/10867.scala b/tests/pos/10867.scala new file mode 100644 index 000000000000..e08b0c60a491 --- /dev/null +++ b/tests/pos/10867.scala @@ -0,0 +1,49 @@ +object Test { + type inserts[a, as <: Tuple] <: Tuple = + as match + case EmptyTuple => (a *: EmptyTuple) *: EmptyTuple + case y *: ys => (a *: y *: ys) *: Tuple.Map[inserts[a, ys], [t <: Tuple] =>> y *: t] + + type inserts2[a] = + [as <: Tuple] =>> inserts[a, as] + + type A = inserts [1, EmptyTuple] + type B = inserts2[1][EmptyTuple] + + summon[A =:= ((1 *: EmptyTuple) *: EmptyTuple)] + summon[B =:= ((1 *: EmptyTuple) *: EmptyTuple)] + summon[A =:= B] + + type H[t <: Tuple] = Tuple.Concat[t, EmptyTuple] + + summon[H[A] =:= H[B]] + + summon[Tuple.Concat[A, EmptyTuple] =:= Tuple.Concat[B, EmptyTuple]] +} + +object Minimized { + type Concombre[X <: Tuple, +Y <: Tuple] <: Tuple = X match { + case EmptyTuple => Y + case x1 *: xs1 => X + } + + type inserts[a, as <: Tuple] <: Tuple = + as match + case EmptyTuple => a *: EmptyTuple + + type inserts2[a] = + [as <: Tuple] =>> inserts[a, as] + + type A = inserts [1, EmptyTuple] + type B = inserts2[1][EmptyTuple] + type C = 1 *: EmptyTuple + + summon[A =:= B] + summon[A =:= C] + summon[B =:= C] + + type H[t <: Tuple] = Concombre[t, EmptyTuple] + + summon[H[C] =:= H[A]] + summon[H[C] =:= H[B]] +}