Permalink
Browse files

Confirm extractor based pattern matches don't explode exponentially.

Closes SI-1133, thanks virtpatmat.
  • Loading branch information...
retronym committed May 12, 2012
1 parent 3511e59 commit ba123f081f05c46475248a1309df406a2c766dce
Showing with 32 additions and 0 deletions.
  1. +32 −0 test/files/pos/t1133.scala
View
@@ -0,0 +1,32 @@
object Match
{
def main(args: Array[String]) = {
args(0) match {
case Extractor1(Extractor2(Extractor3("dog", "dog", "dog"), x2, x3), b, c, Extractor3("b", "b", f), e) => println(e)
case Extractor3(Extractor2(Extractor1("a", "aa", "aaa", "aa", "a"), Extractor2("a", "aa", "aaa"), e), y, z) => println(e)
case Extractor2(Extractor3("a", "a", x), Extractor3("b", "b", y), Extractor3("c", "c", z)) => println(z)
case _ => println("fail")
}
}
object Extractor1 {
def unapply(x: Any) = x match {
case x: String => Some(x, x+x, x+x+x, x+x, x)
case _ => None
}
}
object Extractor2 {
def unapply(x: Any) = x match {
case x: String => Some(x, x+x, x+x+x)
case _ => None
}
}
object Extractor3 {
def unapply(x: Any) = x match {
case x: String => Some(x, x, x)
case _ => None
}
}
}

0 comments on commit ba123f0

Please sign in to comment.