summaryrefslogtreecommitdiff
path: root/test/files/run/t7868.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-23 10:35:43 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-09-23 10:42:48 +0200
commit16d963bcb032deb669247e4a95c6391971cafd75 (patch)
treef2dd541f9345d2624069c097d18ae1e8509c87a2 /test/files/run/t7868.scala
parent65817bd2b71f5ea0e39af1b1c2b085562cd8e925 (diff)
downloadscala-16d963bcb032deb669247e4a95c6391971cafd75.tar.gz
scala-16d963bcb032deb669247e4a95c6391971cafd75.tar.bz2
scala-16d963bcb032deb669247e4a95c6391971cafd75.zip
SI-7868 Account for numeric widening in match translation
Pattern match translation was unprepared for trees of the shape: (0: Short) match { case A.unapply(<unapply-selector>.toInt) <unapply> (_) => () case _ => () } While a scrutinee is inelibigle for implicit views in order to conform to the type of the extractor call, it is allowed to weakly conform. In this case, the typechecker will add the numeric widening with a `toInt` call. This commit: - Changes treeInfo.Unapplied to recognize this tree shape - Changes spliceApply to recognize and preserve the widening when substituting the unapply selector with the binder - Tests reification of such pattern matches, which also depends on treeInfo.Unapplied.
Diffstat (limited to 'test/files/run/t7868.scala')
-rw-r--r--test/files/run/t7868.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/files/run/t7868.scala b/test/files/run/t7868.scala
new file mode 100644
index 0000000000..1f938adf31
--- /dev/null
+++ b/test/files/run/t7868.scala
@@ -0,0 +1,13 @@
+object A {
+ def unapply(n: Int): Option[Int] = Some(n)
+
+ def run = (0: Short) match {
+ case A(_) =>
+ case _ =>
+ }
+}
+
+
+object Test extends App {
+ A.run
+}