diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-27 06:12:12 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-27 06:12:12 -0700 |
commit | 76f3885ac875f03738092157bba5a640698b156a (patch) | |
tree | b72d86244b4683714c0370cb184a813f2b008d29 /test | |
parent | 8a099ba91a7426d2839ed4a747568ae1857531c5 (diff) | |
parent | 22834ee32e8471a8ab33e194d7469686d60ef7d5 (diff) | |
download | scala-76f3885ac875f03738092157bba5a640698b156a.tar.gz scala-76f3885ac875f03738092157bba5a640698b156a.tar.bz2 scala-76f3885ac875f03738092157bba5a640698b156a.zip |
Merge pull request #778 from adriaanm/topic-virtpatmat
patmat bugfixes and minor clean ups
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t2442.check | 9 | ||||
-rw-r--r-- | test/files/neg/t2442.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t2442/MyEnum.java | 3 | ||||
-rw-r--r-- | test/files/neg/t2442/MySecondEnum.java | 6 | ||||
-rw-r--r-- | test/files/neg/t2442/t2442.scala | 15 | ||||
-rw-r--r-- | test/files/pos/t5899.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t5899.scala | 19 | ||||
-rw-r--r-- | test/files/run/t5914.check | 1 | ||||
-rw-r--r-- | test/files/run/t5914.scala | 23 |
9 files changed, 78 insertions, 0 deletions
diff --git a/test/files/neg/t2442.check b/test/files/neg/t2442.check new file mode 100644 index 0000000000..714816fd62 --- /dev/null +++ b/test/files/neg/t2442.check @@ -0,0 +1,9 @@ +t2442.scala:4: error: match may not be exhaustive. +It would fail on the following input: THREE + def f(e: MyEnum) = e match { + ^ +t2442.scala:11: error: match may not be exhaustive. +It would fail on the following input: BLUE + def g(e: MySecondEnum) = e match { + ^ +two errors found diff --git a/test/files/neg/t2442.flags b/test/files/neg/t2442.flags new file mode 100644 index 0000000000..32cf036c3d --- /dev/null +++ b/test/files/neg/t2442.flags @@ -0,0 +1 @@ +-Xexperimental -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t2442/MyEnum.java b/test/files/neg/t2442/MyEnum.java new file mode 100644 index 0000000000..3ffbbb31b8 --- /dev/null +++ b/test/files/neg/t2442/MyEnum.java @@ -0,0 +1,3 @@ +public enum MyEnum { + ONE, TWO, THREE; +}
\ No newline at end of file diff --git a/test/files/neg/t2442/MySecondEnum.java b/test/files/neg/t2442/MySecondEnum.java new file mode 100644 index 0000000000..0f841286de --- /dev/null +++ b/test/files/neg/t2442/MySecondEnum.java @@ -0,0 +1,6 @@ +public enum MySecondEnum { + RED(1), BLUE(2) { public void foo() {} }; + MySecondEnum(int i) {} + + public void foo() {} +}
\ No newline at end of file diff --git a/test/files/neg/t2442/t2442.scala b/test/files/neg/t2442/t2442.scala new file mode 100644 index 0000000000..b0a0f3cd41 --- /dev/null +++ b/test/files/neg/t2442/t2442.scala @@ -0,0 +1,15 @@ +class Test { + import MyEnum._ + + def f(e: MyEnum) = e match { + case ONE => println("one") + case TWO => println("two") + // missing case --> exhaustivity warning! + } + + import MySecondEnum._ + def g(e: MySecondEnum) = e match { + case RED => println("red") + // missing case --> exhaustivity warning! + } +}
\ No newline at end of file diff --git a/test/files/pos/t5899.flags b/test/files/pos/t5899.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t5899.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t5899.scala b/test/files/pos/t5899.scala new file mode 100644 index 0000000000..b16f1f84fe --- /dev/null +++ b/test/files/pos/t5899.scala @@ -0,0 +1,19 @@ +import scala.tools.nsc._ + +trait Foo { + val global: Global + import global.{Name, Symbol, nme} + + case class Bippy(name: Name) + + def f(x: Bippy, sym: Symbol): Int = { + // no warning (!) for + // val Stable = sym.name.toTermName + + val Stable = sym.name + Bippy(Stable) match { + case Bippy(nme.WILDCARD) => 1 + case Bippy(Stable) => 2 // should not be considered unreachable + } + } +}
\ No newline at end of file diff --git a/test/files/run/t5914.check b/test/files/run/t5914.check new file mode 100644 index 0000000000..818e321255 --- /dev/null +++ b/test/files/run/t5914.check @@ -0,0 +1 @@ +correct diff --git a/test/files/run/t5914.scala b/test/files/run/t5914.scala new file mode 100644 index 0000000000..45d8815738 --- /dev/null +++ b/test/files/run/t5914.scala @@ -0,0 +1,23 @@ +import scala.reflect.ClassTag + +trait Trees { + class Tree + implicit val ttTag: ClassTag[TypeTree] + type TypeTree <: Tree + val TypeTree: TypeTreeExtractor + abstract class TypeTreeExtractor { + def unapply(t: TypeTree): Option[String] + } + def test(tree: Tree) = + tree match { + case TypeTree(_) => println("lolwut") + case null => println("correct") + } +} + +object Test extends App with Trees { + val ttTag = implicitly[ClassTag[TypeTree]] + case class TypeTree(meh: String) extends Tree + object TypeTree extends TypeTreeExtractor + test(null) // should not crash +}
\ No newline at end of file |