From fc0b8644beb564d10ee7f4ea28209aa2053fa1cb Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 22 Jun 2012 09:59:23 +0200 Subject: SI-2442 fixed by virtpatmat -- test files only --- test/files/neg/t2442.check | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/files/neg/t2442.check (limited to 'test/files/neg/t2442.check') diff --git a/test/files/neg/t2442.check b/test/files/neg/t2442.check new file mode 100644 index 0000000000..b45ce3a2f5 --- /dev/null +++ b/test/files/neg/t2442.check @@ -0,0 +1,5 @@ +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 -- cgit v1.2.3 From 22834ee32e8471a8ab33e194d7469686d60ef7d5 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Wed, 27 Jun 2012 11:14:24 +0200 Subject: 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 --- test/files/neg/t2442.check | 6 +++++- test/files/neg/t2442/MySecondEnum.java | 6 ++++++ test/files/neg/t2442/t2442.scala | 6 ++++++ test/files/run/t5914.scala | 26 ++++++++++++++++++++------ 4 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 test/files/neg/t2442/MySecondEnum.java (limited to 'test/files/neg/t2442.check') 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 -- cgit v1.2.3