aboutsummaryrefslogtreecommitdiff
path: root/tests/run
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run')
-rw-r--r--tests/run/i1991.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/run/i1991.scala b/tests/run/i1991.scala
new file mode 100644
index 000000000..cec1dec89
--- /dev/null
+++ b/tests/run/i1991.scala
@@ -0,0 +1,29 @@
+import scala.reflect.ClassTag
+
+class A[Foo](implicit tag: ClassTag[Foo]) {
+ object ExtractFoo {
+ def unapply(foo: Foo): Boolean = true
+ }
+
+ def isFoo(x: Any) = x match {
+ case ExtractFoo() => true
+ //case foo: Foo => true
+ case _ => false
+ }
+
+ def testBind(x: Any) = x match {
+ case foo0: Foo =>
+ (foo0: Foo)
+ case foo1 @ (_: Foo) =>
+ (foo1: Foo)
+ case foo2 @ ExtractFoo() =>
+ (foo2: Foo)
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert((new A[String]).isFoo("foo")) // OK
+ assert(!(new A[String]).isFoo(42)) // OK in scalac, fails in Dotty
+ }
+}