diff options
author | Martin Odersky <odersky@gmail.com> | 2017-02-17 16:38:06 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-02-17 16:38:06 +0100 |
commit | 80511914713237de894f896da7397965e52134a7 (patch) | |
tree | 0413b633ef8baafe30eb86188c59b78a31fca2ba /tests/run/i1991.scala | |
parent | 6df672c7e7be65d7be1cd6524c610aed4f35178c (diff) | |
download | dotty-80511914713237de894f896da7397965e52134a7.tar.gz dotty-80511914713237de894f896da7397965e52134a7.tar.bz2 dotty-80511914713237de894f896da7397965e52134a7.zip |
Fix #1991: Use classtag where available in unapply
Diffstat (limited to 'tests/run/i1991.scala')
-rw-r--r-- | tests/run/i1991.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/run/i1991.scala b/tests/run/i1991.scala new file mode 100644 index 000000000..524a3f311 --- /dev/null +++ b/tests/run/i1991.scala @@ -0,0 +1,20 @@ +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 + } +} + +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 + } +} |