aboutsummaryrefslogtreecommitdiff
path: root/tests/run/i1099.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-02-19 16:33:43 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-20 10:19:58 +0100
commit050c9af51432e3a752715af78b0de577d5af7f87 (patch)
treeefb575e1e362eb4f7e6d5118ae8dc325035ee535 /tests/run/i1099.scala
parent14096e3601e42fd33fb2446b908a5cfce3cf1fa9 (diff)
downloaddotty-050c9af51432e3a752715af78b0de577d5af7f87.tar.gz
dotty-050c9af51432e3a752715af78b0de577d5af7f87.tar.bz2
dotty-050c9af51432e3a752715af78b0de577d5af7f87.zip
Special case for pattern matching tagged abstract types.
Add special case when pattern matching against an abstract type that comes with a class tag
Diffstat (limited to 'tests/run/i1099.scala')
-rw-r--r--tests/run/i1099.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/run/i1099.scala b/tests/run/i1099.scala
new file mode 100644
index 000000000..15a428cc3
--- /dev/null
+++ b/tests/run/i1099.scala
@@ -0,0 +1,25 @@
+import scala.reflect.ClassTag
+object Test {
+ def foo[T: ClassTag](x: Any) =
+ x match {
+ case t: T => true
+ case _ => false
+ }
+ // This is what `foo` expands to
+ def foo2[T](x: Any)(implicit ev: ClassTag[T]) =
+ x match {
+ case t @ ev(_) => true
+ case _ => false
+ }
+ def main(args: Array[String]): Unit = {
+ assert(foo[String]("a"))
+ assert(!foo[String](new Integer(1)))
+ assert(foo[Int](1))
+ assert(!foo[Int](true))
+
+ assert(foo2[String]("a"))
+ assert(!foo2[String](new Integer(1)))
+ assert(foo2[Int](1))
+ assert(!foo2[Int](true))
+ }
+}