Skip to content

Commit 71acf8d

Browse files
authored
Merge pull request #13615 from dotty-staging/backport-10867
[Backport] Normalize after applyIfParameterized in superType
2 parents f2ae513 + f05d09e commit 71acf8d

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -4105,18 +4105,17 @@ object Types {
41054105

41064106
override def underlying(using Context): Type = tycon
41074107

4108-
override def superType(using Context): Type = {
4109-
if (ctx.period != validSuper) {
4110-
cachedSuper = tycon match {
4108+
override def superType(using Context): Type =
4109+
if ctx.period != validSuper then
4110+
validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4111+
cachedSuper = tycon match
41114112
case tycon: HKTypeLambda => defn.AnyType
41124113
case tycon: TypeRef if tycon.symbol.isClass => tycon
4113-
case tycon: TypeProxy => tycon.superType.applyIfParameterized(args)
4114+
case tycon: TypeProxy =>
4115+
if isMatchAlias then validSuper = Nowhere
4116+
tycon.superType.applyIfParameterized(args).normalized
41144117
case _ => defn.AnyType
4115-
}
4116-
validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4117-
}
41184118
cachedSuper
4119-
}
41204119

41214120
override def translucentSuperType(using Context): Type = tycon match {
41224121
case tycon: TypeRef if tycon.symbol.isOpaqueAlias =>

tests/pos-deep-subtype/9849.scala

-4
This file was deleted.

tests/pos/10867.scala

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
object Test {
2+
type inserts[a, as <: Tuple] <: Tuple =
3+
as match
4+
case EmptyTuple => (a *: EmptyTuple) *: EmptyTuple
5+
case y *: ys => (a *: y *: ys) *: Tuple.Map[inserts[a, ys], [t <: Tuple] =>> y *: t]
6+
7+
type inserts2[a] =
8+
[as <: Tuple] =>> inserts[a, as]
9+
10+
type A = inserts [1, EmptyTuple]
11+
type B = inserts2[1][EmptyTuple]
12+
13+
summon[A =:= ((1 *: EmptyTuple) *: EmptyTuple)]
14+
summon[B =:= ((1 *: EmptyTuple) *: EmptyTuple)]
15+
summon[A =:= B]
16+
17+
type H[t <: Tuple] = Tuple.Concat[t, EmptyTuple]
18+
19+
summon[H[A] =:= H[B]]
20+
21+
summon[Tuple.Concat[A, EmptyTuple] =:= Tuple.Concat[B, EmptyTuple]]
22+
}
23+
24+
object Minimized {
25+
type Concombre[X <: Tuple, +Y <: Tuple] <: Tuple = X match {
26+
case EmptyTuple => Y
27+
case x1 *: xs1 => X
28+
}
29+
30+
type inserts[a, as <: Tuple] <: Tuple =
31+
as match
32+
case EmptyTuple => a *: EmptyTuple
33+
34+
type inserts2[a] =
35+
[as <: Tuple] =>> inserts[a, as]
36+
37+
type A = inserts [1, EmptyTuple]
38+
type B = inserts2[1][EmptyTuple]
39+
type C = 1 *: EmptyTuple
40+
41+
summon[A =:= B]
42+
summon[A =:= C]
43+
summon[B =:= C]
44+
45+
type H[t <: Tuple] = Concombre[t, EmptyTuple]
46+
47+
summon[H[C] =:= H[A]]
48+
summon[H[C] =:= H[B]]
49+
}

0 commit comments

Comments
 (0)