Skip to content

Fix #6322: normalize types in baseType #6464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1751,9 +1751,11 @@ object SymDenotations {
Stats.record("computeBaseType, total")
Stats.record(s"computeBaseType, ${tp.getClass}")
}
val normed = tp.tryNormalize
if (normed.exists) return recur(normed)

tp match {
case tp @ TypeRef(prefix, _) =>

def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
case p :: ps1 => foldGlb(bt & recur(p), ps1)
case _ => bt
Expand Down Expand Up @@ -1794,7 +1796,6 @@ object SymDenotations {
computeTypeRef

case tp @ AppliedType(tycon, args) =>

def computeApplied = {
btrCache.put(tp, NoPrefix)
val baseTp =
Expand All @@ -1812,8 +1813,8 @@ object SymDenotations {

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

case tp: TypeProxy =>
def computeTypeProxy = {
val superTp = tp.superType
val baseTp = recur(superTp)
Expand All @@ -1827,7 +1828,6 @@ object SymDenotations {
computeTypeProxy

case tp: AndOrType =>

def computeAndOrType = {
val tp1 = tp.tp1
val tp2 = tp.tp2
Expand All @@ -1851,6 +1851,7 @@ object SymDenotations {

case JavaArrayType(_) if symbol == defn.ObjectClass =>
this.typeRef

case _ =>
NoType
}
Expand Down
7 changes: 5 additions & 2 deletions compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
i1812.scala
i1867.scala
i3067.scala
matchtype.scala
t247.scala
t2712-5.scala
t284-pos.scala
t3249
t3486
t3612.scala
typelevel0.scala
reference

# Match types
typelevel0.scala
matchtype.scala
6322.scala
24 changes: 24 additions & 0 deletions tests/pos/6322.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
object Test {
final class A
final class B
final class C

trait F1[T1] {
def apply(x: T1): Unit
}

type F[N] = N match {
case A => F1[String]
case B => F[A]
case C => F[B]
}

val s1: F[A] = ???
s1.apply("A")

val s2: F[B] = ???
s2.apply("B")

val s3: F[C] = ???
s3.apply("C")
}