Skip to content

Commit f925b40

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

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -1751,9 +1751,11 @@ object SymDenotations {
17511751
Stats.record("computeBaseType, total")
17521752
Stats.record(s"computeBaseType, ${tp.getClass}")
17531753
}
1754+
val normed = tp.tryNormalize
1755+
if (normed.exists) return recur(normed)
1756+
17541757
tp match {
17551758
case tp @ TypeRef(prefix, _) =>
1756-
17571759
def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
17581760
case p :: ps1 => foldGlb(bt & recur(p), ps1)
17591761
case _ => bt
@@ -1794,7 +1796,6 @@ object SymDenotations {
17941796
computeTypeRef
17951797

17961798
case tp @ AppliedType(tycon, args) =>
1797-
17981799
def computeApplied = {
17991800
btrCache.put(tp, NoPrefix)
18001801
val baseTp =
@@ -1812,8 +1813,8 @@ object SymDenotations {
18121813

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

1817+
case tp: TypeProxy =>
18171818
def computeTypeProxy = {
18181819
val superTp = tp.superType
18191820
val baseTp = recur(superTp)
@@ -1827,7 +1828,6 @@ object SymDenotations {
18271828
computeTypeProxy
18281829

18291830
case tp: AndOrType =>
1830-
18311831
def computeAndOrType = {
18321832
val tp1 = tp.tp1
18331833
val tp2 = tp.tp2
@@ -1851,6 +1851,7 @@ object SymDenotations {
18511851

18521852
case JavaArrayType(_) if symbol == defn.ObjectClass =>
18531853
this.typeRef
1854+
18541855
case _ =>
18551856
NoType
18561857
}
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)