summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-06-27 11:14:24 +0200
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-06-27 12:12:40 +0200
commit22834ee32e8471a8ab33e194d7469686d60ef7d5 (patch)
treee6094cd08646d5ddb9901c9af20a6cad3b18fb3c /test/files
parent966c9bbebec78b90a79f72c73b55d9de6db34798 (diff)
downloadscala-22834ee32e8471a8ab33e194d7469686d60ef7d5.tar.gz
scala-22834ee32e8471a8ab33e194d7469686d60ef7d5.tar.bz2
scala-22834ee32e8471a8ab33e194d7469686d60ef7d5.zip
make tests independent of compiler api
TODO: t5899 should also be refactored, but I couldn't figure out how I tried the obvious Cake Light pattern with abstract types etc, but that didn't trigger it there must be something with indirection through paths as well
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/t2442.check6
-rw-r--r--test/files/neg/t2442/MySecondEnum.java6
-rw-r--r--test/files/neg/t2442/t2442.scala6
-rw-r--r--test/files/run/t5914.scala26
4 files changed, 37 insertions, 7 deletions
diff --git a/test/files/neg/t2442.check b/test/files/neg/t2442.check
index b45ce3a2f5..714816fd62 100644
--- a/test/files/neg/t2442.check
+++ b/test/files/neg/t2442.check
@@ -2,4 +2,8 @@ t2442.scala:4: error: match may not be exhaustive.
It would fail on the following input: THREE
def f(e: MyEnum) = e match {
^
-one error found
+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/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
index 4ca0889400..b0a0f3cd41 100644
--- a/test/files/neg/t2442/t2442.scala
+++ b/test/files/neg/t2442/t2442.scala
@@ -6,4 +6,10 @@ class Test {
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/run/t5914.scala b/test/files/run/t5914.scala
index 53cae9be74..45d8815738 100644
--- a/test/files/run/t5914.scala
+++ b/test/files/run/t5914.scala
@@ -1,9 +1,23 @@
-import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
-object Test extends App {
- val tree: Tree = null
- tree match {
- case TypeTree() => println("lolwut")
- case null => println("correct")
+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