diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-05-23 02:42:06 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-05-23 02:42:06 -0700 |
commit | cebf241ad87358b0e8d2804750a4ac36e76f7091 (patch) | |
tree | 29e04607f5bf666bed4f8d78d1b757f0763fdd1e /test/files/pos/virtpatmat_exhaust.scala | |
parent | 2e7daa10097246c03df1f77aebc85f1ecdebb7e9 (diff) | |
parent | 3f7b8b58748eb70aec4269f1ef63853b5ad4af60 (diff) | |
download | scala-cebf241ad87358b0e8d2804750a4ac36e76f7091.tar.gz scala-cebf241ad87358b0e8d2804750a4ac36e76f7091.tar.bz2 scala-cebf241ad87358b0e8d2804750a4ac36e76f7091.zip |
Merge pull request #601 from adriaanm/3f7b8b58748eb70aec4269f1ef63853b5ad4af60
virtpatmat: treemaker approximation refactorings and exhaustivity
Diffstat (limited to 'test/files/pos/virtpatmat_exhaust.scala')
-rw-r--r-- | test/files/pos/virtpatmat_exhaust.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/pos/virtpatmat_exhaust.scala b/test/files/pos/virtpatmat_exhaust.scala new file mode 100644 index 0000000000..a2f47c88c8 --- /dev/null +++ b/test/files/pos/virtpatmat_exhaust.scala @@ -0,0 +1,24 @@ +sealed trait Option {} +case class Choice(a: Option, b: Option) extends Option; +case class Some(x: Boolean) extends Option; +case object None extends Option; + +object test { + +// drop any case and it will report an error +// note that booleans are taken into account + def f(opt: Option) = opt match { + case Choice(None, None) => 1; + case Choice(None, Some(_)) => 1; + case Choice(None, Choice(_, _)) => 1; + case Choice(Some(true), None) => 1; + case Choice(Some(false), None) => 1; + case Choice(Some(_), Some(_)) => 1; + case Choice(Some(_), Choice(_, _)) => 1; + case Choice(Choice(_, _), None) => 1; + case Choice(Choice(_, _), Some(_)) => 1; + case Choice(Choice(_, _), Choice(_, _)) => 1; + case Some(b) => 4; + case None => 5; + } +} |