aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
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
+ }
+
+}