Skip to content

Fix #2253 edge cases: recurse into refined type #2261

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
Apr 14, 2017
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
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,12 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
tp.refinedName,
tpb.derivedTypeBounds(follow(lo, false), follow(hi, true))
)
case tp => tp
case _ =>
tp.derivedRefinedType(
expose(tp.parent),
tp.refinedName,
tp.refinedInfo
)
}
case _ => tp
}
Expand Down
3 changes: 3 additions & 0 deletions tests/patmat/i2253.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
27: Pattern Match Exhaustivity: HasIntXIntM, HasIntXStringM
28: Pattern Match Exhaustivity: HasIntXIntM
29: Pattern Match Exhaustivity: HasIntXIntM
29 changes: 26 additions & 3 deletions tests/patmat/i2253.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
sealed trait S
object O extends S

object BodylessObject extends S

object HasIntM extends S {
type M = Int
}

object HasStringXStringM extends S {
type M = String
val x: String = ""
}

object HasIntXStringM extends S {
type M = String
val x: Int = 0
}

object HasIntXIntM extends S {
type M = Int
val x: Int = 0
}

trait T

class Test {
def m(s: S { val x: Int }) = s match { case _: T => ; }
}
def onlyIntX(s: S { val x: Int }) = s match { case _: T => ; }
def exposeAlias1[I <: Int](s: S { type M = I; val x: Int }) = s match { case _: T => ; }
def exposeAlias2[I <: Int](s: S { val x: Int; type M = I }) = s match { case _: T => ; }
}