Skip to content

Commit f480752

Browse files
Fix #6322: normalize types in baseType
1 parent 2869bb3 commit f480752

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1751,9 +1751,10 @@ object SymDenotations {
17511751
Stats.record("computeBaseType, total")
17521752
Stats.record(s"computeBaseType, ${tp.getClass}")
17531753
}
1754+
val normed = tp.normalized
1755+
if (normed.ne(tp)) return recur(normed)
17541756
tp match {
17551757
case tp @ TypeRef(prefix, _) =>
1756-
17571758
def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
17581759
case p :: ps1 => foldGlb(bt & recur(p), ps1)
17591760
case _ => bt
@@ -1794,7 +1795,6 @@ object SymDenotations {
17941795
computeTypeRef
17951796

17961797
case tp @ AppliedType(tycon, args) =>
1797-
17981798
def computeApplied = {
17991799
btrCache.put(tp, NoPrefix)
18001800
val baseTp =
@@ -1812,8 +1812,8 @@ object SymDenotations {
18121812

18131813
case tp: TypeParamRef => // uncachable, since baseType depends on context bounds
18141814
recur(ctx.typeComparer.bounds(tp).hi)
1815-
case tp: TypeProxy =>
18161815

1816+
case tp: TypeProxy =>
18171817
def computeTypeProxy = {
18181818
val superTp = tp.superType
18191819
val baseTp = recur(superTp)
@@ -1827,7 +1827,6 @@ object SymDenotations {
18271827
computeTypeProxy
18281828

18291829
case tp: AndOrType =>
1830-
18311830
def computeAndOrType = {
18321831
val tp1 = tp.tp1
18331832
val tp2 = tp.tp2
@@ -1851,6 +1850,7 @@ object SymDenotations {
18511850

18521851
case JavaArrayType(_) if symbol == defn.ObjectClass =>
18531852
this.typeRef
1853+
18541854
case _ =>
18551855
NoType
18561856
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
i1812.scala
22
i1867.scala
33
i3067.scala
4-
matchtype.scala
54
t247.scala
65
t2712-5.scala
76
t284-pos.scala
87
t3249
98
t3486
109
t3612.scala
11-
typelevel0.scala
1210
reference
11+
12+
# Match types
13+
typelevel0.scala
14+
matchtype.scala
15+
6322.scala

tests/pos/6322.scala

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
object Test {
2+
final class A
3+
final class B
4+
final class C
5+
6+
trait F1[T1] {
7+
def apply(x: T1): Unit
8+
}
9+
10+
type F[N] = N match {
11+
case A => F1[String]
12+
case B => F[A]
13+
case C => F[B]
14+
}
15+
16+
val s1: F[A] = ???
17+
s1.apply("A")
18+
19+
val s2: F[B] = ???
20+
s2.apply("B")
21+
22+
val s3: F[C] = ???
23+
s3.apply("C")
24+
}

0 commit comments

Comments
 (0)