aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail.com>2017-04-13 22:17:43 +0200
committerAleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail.com>2017-04-13 22:17:43 +0200
commit1c900a35155c0b92fd3b96794ffb55c0b0c03d9c (patch)
treecaa559734278467838c669565f91a91803f32918
parent9e45ad16d012e6a2ff3be411c2fe101b1c74b831 (diff)
downloaddotty-1c900a35155c0b92fd3b96794ffb55c0b0c03d9c.zip
dotty-1c900a35155c0b92fd3b96794ffb55c0b0c03d9c.tar.gz
dotty-1c900a35155c0b92fd3b96794ffb55c0b0c03d9c.tar.bz2
Recurse into refined type when exposing members
-rw-r--r--compiler/src/dotty/tools/dotc/transform/patmat/Space.scala7
-rw-r--r--tests/patmat/i2253.check3
-rw-r--r--tests/patmat/i2253.scala29
3 files changed, 35 insertions, 4 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
index fe29838..53518ec 100644
--- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
+++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
@@ -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
}
diff --git a/tests/patmat/i2253.check b/tests/patmat/i2253.check
new file mode 100644
index 0000000..5c86a1e
--- /dev/null
+++ b/tests/patmat/i2253.check
@@ -0,0 +1,3 @@
+27: Pattern Match Exhaustivity: HasIntXIntM, HasIntXStringM
+28: Pattern Match Exhaustivity: HasIntXIntM
+29: Pattern Match Exhaustivity: HasIntXIntM
diff --git a/tests/patmat/i2253.scala b/tests/patmat/i2253.scala
index 8394a86..0344a6a 100644
--- a/tests/patmat/i2253.scala
+++ b/tests/patmat/i2253.scala
@@ -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 => ; }
-} \ No newline at end of file
+ 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 => ; }
+}