summaryrefslogtreecommitdiff
path: root/test/files/run/t6146b.check
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-01-31 00:33:19 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-02-07 21:58:47 +0100
commit55c9b9c280ac9bc36bbac09397c7646f8dcf4583 (patch)
treecdfc1cd396eaba78f0150968634722bcb8df8bd7 /test/files/run/t6146b.check
parent81d8f9d3da656cfb05f125ba7cf70ca51a477240 (diff)
downloadscala-55c9b9c280ac9bc36bbac09397c7646f8dcf4583.tar.gz
scala-55c9b9c280ac9bc36bbac09397c7646f8dcf4583.tar.bz2
scala-55c9b9c280ac9bc36bbac09397c7646f8dcf4583.zip
SI-6146 More accurate prefixes for sealed subtypes.
When analysing exhaustivity/reachability of type tests and equality tests, the pattern matcher must construct a set of sealed subtypes based on the prefix of the static type of and the set of sealed descendent symbols of that type. Previously, it was using `memberType` for this purpose. In simple cases, this is sufficient: scala> class C { class I1; object O { class I2 } }; object D extends C defined class C defined module D scala> typeOf[D.type] memberType typeOf[C#I1].typeSymbol res0: u.Type = D.I1 But, as reported in this bug, it fails when there is an additional level of nesting: scala> typeOf[D.type] memberType typeOf[c.O.I2 forSome { val c: C }].typeSymbol res5: u.Type = C.O.I2 This commit introduces `nestedMemberType`, which uses `memberType` recursively up the prefix chain prefix chain. scala> nestedMemberType(typeOf[c.O.I2 forSome { val c: C }].typeSymbol, typeOf[D.type], typeOf[C].typeSymbol) res6: u.Type = D.O.Id
Diffstat (limited to 'test/files/run/t6146b.check')
-rw-r--r--test/files/run/t6146b.check52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/files/run/t6146b.check b/test/files/run/t6146b.check
new file mode 100644
index 0000000000..b664d1152a
--- /dev/null
+++ b/test/files/run/t6146b.check
@@ -0,0 +1,52 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> :power
+** Power User mode enabled - BEEP WHIR GYVE **
+** :phase has been set to 'typer'. **
+** scala.tools.nsc._ has been imported **
+** global._, definitions._ also imported **
+** Try :help, :vals, power.<tab> **
+
+scala> val u = rootMirror.universe; import u._, language._
+u: $r.intp.global.type = <global>
+import u._
+import language._
+
+scala> val S1 = typeOf[c.X.S1.type forSome { val c: C[_] }].typeSymbol.tpeHK
+S1: u.Type = C.X.S1.type
+
+scala> val S2 = typeOf[O.S2].typeSymbol.tpeHK
+S2: u.Type = C.this.S2
+
+scala> val S3 = typeOf[O.S3].typeSymbol.tpeHK
+S3: u.Type = O.S3
+
+scala> val S4 = typeOf[S4].typeSymbol.tpeHK
+S4: u.Type = S4
+
+scala> val F = typeOf[c.F[_] forSome { val c: C[_] }].typeSymbol.tpeHK
+F: u.Type = C.this.F
+
+scala> val fTpe = typeOf[O.type].decl(newTermName("foo")).paramss.head.head.tpe
+fTpe: u.Type = O.F[Int]
+
+scala> def memType(sub: Type, scrut: Type): Type =
+ nestedMemberType(sub.typeSymbol, scrut.prefix, scrut.typeSymbol.owner)
+memType: (sub: u.Type, scrut: u.Type)u.Type
+
+scala>
+
+scala> memType(S1, fTpe)
+res0: u.Type = O.X.S1.type
+
+scala> memType(S2, fTpe)
+res1: u.Type = O.S2
+
+scala> memType(S3, fTpe)
+res2: u.Type = O.S3
+
+scala> memType(S4, fTpe)
+res3: u.Type = S4
+
+scala>