Skip to content

Commit a5ac12d

Browse files
Merge pull request #6464 from dotty-staging/fix-6322
Fix #6322: normalize types in baseType
2 parents f54af21 + f925b40 commit a5ac12d

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
@@ -1754,9 +1754,11 @@ object SymDenotations {
17541754
Stats.record("computeBaseType, total")
17551755
Stats.record(s"computeBaseType, ${tp.getClass}")
17561756
}
1757+
val normed = tp.tryNormalize
1758+
if (normed.exists) return recur(normed)
1759+
17571760
tp match {
17581761
case tp @ TypeRef(prefix, _) =>
1759-
17601762
def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
17611763
case p :: ps1 => foldGlb(bt & recur(p), ps1)
17621764
case _ => bt
@@ -1797,7 +1799,6 @@ object SymDenotations {
17971799
computeTypeRef
17981800

17991801
case tp @ AppliedType(tycon, args) =>
1800-
18011802
def computeApplied = {
18021803
btrCache.put(tp, NoPrefix)
18031804
val baseTp =
@@ -1815,8 +1816,8 @@ object SymDenotations {
18151816

18161817
case tp: TypeParamRef => // uncachable, since baseType depends on context bounds
18171818
recur(ctx.typeComparer.bounds(tp).hi)
1818-
case tp: TypeProxy =>
18191819

1820+
case tp: TypeProxy =>
18201821
def computeTypeProxy = {
18211822
val superTp = tp.superType
18221823
val baseTp = recur(superTp)
@@ -1830,7 +1831,6 @@ object SymDenotations {
18301831
computeTypeProxy
18311832

18321833
case tp: AndOrType =>
1833-
18341834
def computeAndOrType = {
18351835
val tp1 = tp.tp1
18361836
val tp2 = tp.tp2
@@ -1854,6 +1854,7 @@ object SymDenotations {
18541854

18551855
case JavaArrayType(_) if symbol == defn.ObjectClass =>
18561856
this.typeRef
1857+
18571858
case _ =>
18581859
NoType
18591860
}
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)