aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-04-27 13:59:17 +0200
committerMartin Odersky <odersky@gmail.com>2016-04-27 14:01:42 +0200
commit42b20d7143eb3da8dbe536ef990ceef4ec861b25 (patch)
tree1946bab1daf2f58cc4ff4a2f69f100e593d0713b /tests
parent6c0184b157dd218d4b6f854e7142efdf074e596c (diff)
downloaddotty-42b20d7143eb3da8dbe536ef990ceef4ec861b25.tar.gz
dotty-42b20d7143eb3da8dbe536ef990ceef4ec861b25.tar.bz2
dotty-42b20d7143eb3da8dbe536ef990ceef4ec861b25.zip
Better error diagnostics for "not an extractor" errors.
Now explains in detail why an possibly found unapply or unapplySeq is ineligible.
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/extractors.scala27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/neg/extractors.scala b/tests/neg/extractors.scala
new file mode 100644
index 000000000..88600da76
--- /dev/null
+++ b/tests/neg/extractors.scala
@@ -0,0 +1,27 @@
+object A {}
+
+object B {
+
+ def unapply[T](x: T): Option[x.type] = ???
+
+}
+
+object C {
+ def unapply[T](x: T, y: T): Option[T] = ???
+}
+
+object D {
+ def unapply[T](): Option[T] = ???
+}
+
+object Test {
+
+ val x: Any = ???
+ x match {
+ case A(y) => ??? // error: A cannot be used as an extractor in a pattern it lacks a unapply or unapplySeq method
+ case B(y) => ??? // error: B cannot be used as an extractor in a pattern its unapply method of type (x: T)Option[T(x)] has a dependent type
+ case C(y) => ??? // error: C cannot be used as an extractor in a pattern its unapply method of type (x: T, y: T)Option[T] does not take a single parameter
+ case D(y) => ??? // error: D cannot be used as an extractor in a pattern its unapply method of type ()Option[T] does not take a single parameter
+ }
+
+}