diff options
author | Paul Phillips <paulp@improving.org> | 2013-08-17 08:57:53 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-08-17 10:58:13 -0700 |
commit | 35775a8fc87e9f3538e13e8d26f9b151138efe8c (patch) | |
tree | a1df773f6a75d87feb6913890fdfb6be42cf90bf /test/files/neg/t4425b.scala | |
parent | e611eeaf4573db8ec16a38cb00705391496ebe0e (diff) | |
download | scala-35775a8fc87e9f3538e13e8d26f9b151138efe8c.tar.gz scala-35775a8fc87e9f3538e13e8d26f9b151138efe8c.tar.bz2 scala-35775a8fc87e9f3538e13e8d26f9b151138efe8c.zip |
SI-4425 do some validity checking on unapplies.
Filter out unapplies which can't be called (such as those with
a second non-implicit parameter list) and report the error in a
meaningful fashion.
Diffstat (limited to 'test/files/neg/t4425b.scala')
-rw-r--r-- | test/files/neg/t4425b.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/files/neg/t4425b.scala b/test/files/neg/t4425b.scala new file mode 100644 index 0000000000..861e9521f6 --- /dev/null +++ b/test/files/neg/t4425b.scala @@ -0,0 +1,38 @@ +object Test1 { + object X { def unapply(x : String)(y: String) = throw new Exception } + + def f1() { + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + println( "" match { case X(_) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_) => "ok" ; case _ => "fail" }) + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + } +} + +object Test2 { + object X { def unapply(x : String) = throw new Exception } + + def f1() { + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + println( "" match { case X(_) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_) => "ok" ; case _ => "fail" }) + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + } +} + +object Test3 { + object X { def unapply(x : String) = None } + + def f1() { + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + println( "" match { case X(_) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_) => "ok" ; case _ => "fail" }) + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + } +} |