summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-02-07 21:39:12 -0800
committerJames Iry <jamesiry@gmail.com>2013-02-07 21:39:12 -0800
commit4c08eb604f6a23077fd1c65d0bb073ea94389961 (patch)
tree1168b9588c803586d459059b91bdc7d87130ec35 /test/files/pos
parent6bcb830c080c846a7ad4bf5e1949f6b2d02d45fe (diff)
parent55c9b9c280ac9bc36bbac09397c7646f8dcf4583 (diff)
downloadscala-4c08eb604f6a23077fd1c65d0bb073ea94389961.tar.gz
scala-4c08eb604f6a23077fd1c65d0bb073ea94389961.tar.bz2
scala-4c08eb604f6a23077fd1c65d0bb073ea94389961.zip
Merge pull request #2088 from retronym/ticket/6146
SI-6146 More accurate prefixes for sealed subtypes.
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/t6146.flags1
-rw-r--r--test/files/pos/t6146.scala60
2 files changed, 61 insertions, 0 deletions
diff --git a/test/files/pos/t6146.flags b/test/files/pos/t6146.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/pos/t6146.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t6146.scala b/test/files/pos/t6146.scala
new file mode 100644
index 0000000000..b5bde826b1
--- /dev/null
+++ b/test/files/pos/t6146.scala
@@ -0,0 +1,60 @@
+// No unreachable or exhaustiveness warnings, please.
+
+//
+// The reported bug
+//
+
+trait AxisCompanion {
+ sealed trait Format
+ object Format {
+ case object Decimal extends Format
+ case object Integer extends Format
+ // Gives an unrelated warning: The outer reference in this type test cannot be checked at run time.
+ //final case class Time( hours: Boolean = false, millis: Boolean = true ) extends Format
+ }
+}
+object Axis extends AxisCompanion
+class Axis {
+ import Axis._
+ def test( f: Format ) = f match {
+ case Format.Integer => "Int"
+ // case Format.Time( hours, millis ) => "Time"
+ case Format.Decimal => "Dec"
+ }
+}
+
+
+//
+// Some tricksier variations
+//
+
+trait T1[X] {
+ trait T2[Y] {
+ sealed trait Format
+ object Format {
+ case object Decimal extends Format
+ case object Integer extends Format
+ }
+ }
+}
+
+object O1 extends T1[Any] {
+ object O2 extends T2[Any] {
+
+ }
+}
+
+case object Shorty extends O1.O2.Format
+
+class Test1 {
+ import O1.O2._
+ val FI: Format.Integer.type = Format.Integer
+ def test( f: Format ) = {
+ val ff: f.type = f
+ ff match {
+ case FI => "Int"
+ case Format.Decimal => "Dec"
+ case Shorty => "Sho"
+ }
+ }
+}