diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-10-20 22:29:20 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-10-20 22:29:20 +0000 |
commit | 8a9fd64129926eea35f7dca181242855f14e153f (patch) | |
tree | 4defd18749999b6e14d9fba1ccc5e1507b453a64 /test/files/run/virtpatmat_partial.scala | |
parent | 891a6e466b1b22b93c091d590178f7e5410f608e (diff) | |
download | scala-8a9fd64129926eea35f7dca181242855f14e153f.tar.gz scala-8a9fd64129926eea35f7dca181242855f14e153f.tar.bz2 scala-8a9fd64129926eea35f7dca181242855f14e153f.zip |
virtpatmat, hidden behind -Yvirtpatmat
at least one imminent TODO: undo hardwired generation of if/then/else,
and decide based on type whether to call flatMap/orElse or inline those
methods from Option
review by extempore
Diffstat (limited to 'test/files/run/virtpatmat_partial.scala')
-rw-r--r-- | test/files/run/virtpatmat_partial.scala | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/files/run/virtpatmat_partial.scala b/test/files/run/virtpatmat_partial.scala new file mode 100644 index 0000000000..d30944efb4 --- /dev/null +++ b/test/files/run/virtpatmat_partial.scala @@ -0,0 +1,73 @@ +object Test extends App { + val a = Map("a" -> Some(1), "b" -> None) + println(a) + + val res = a collect {case (p, Some(a)) => (p, a)} + + // should uncurry to: + // val res: Map[String,Int] = a.collect[(String, Int), Map[String,Int]]( + // new PartialFunction[(String, Option[Int]),(String, Int)] { + // def apply(x0_1: (String, Option[Int])): (String, Int) = MatchingStrategy.OptionMatchingStrategy.runOrElse[(String, Option[Int]), (String, Int)](x0_1)( + // (x1: (String, Option[Int])) => { + // val o9: Option[(String, Int)] = ({ + // val o8: Option[(String, Option[Int])] = Tuple2.unapply[String, Option[Int]](x1); + // if (o8.isEmpty) + // MatchingStrategy.OptionMatchingStrategy.zero + // else + // { + // val o7: Option[Some[Int]] = if (o8.get._2.isInstanceOf[Some[Int]]) + // MatchingStrategy.OptionMatchingStrategy.one[Some[Int]](o8.get._2.asInstanceOf[Some[Int]]) + // else + // MatchingStrategy.OptionMatchingStrategy.zero; + // if (o7.isEmpty) + // MatchingStrategy.OptionMatchingStrategy.zero + // else + // { + // val o6: Option[Int] = Some.unapply[Int](o7.get); + // if (o6.isEmpty) + // MatchingStrategy.OptionMatchingStrategy.zero + // else + // MatchingStrategy.OptionMatchingStrategy.one[(String, Int)]((o8.get._1, o6.get).asInstanceOf[(String, Int)]) + // } + // } + // }: Option[(String, Int)]); + // if (o9.isEmpty) + // (MatchingStrategy.OptionMatchingStrategy.zero: Option[(String, Int)]) + // else + // o9 + // }) + // + // def isDefinedAt(x_1: (String, Option[Int])): Boolean = MatchingStrategy.OptionMatchingStrategy.isSuccess[(String, Option[Int]), (String, Int)](x_1)( + // (x1: (String, Option[Int])) => { + // val o9: Option[(String, Int)] = ({ + // val o8: Option[(String, Option[Int])] = scala.Tuple2.unapply[String, Option[Int]](x1); + // if (o8.isEmpty) + // MatchingStrategy.OptionMatchingStrategy.zero + // else + // { + // val o7: Option[Some[Int]] = if (o8.get._2.isInstanceOf[Some[Int]]) + // MatchingStrategy.OptionMatchingStrategy.one[Some[Int]](o8.get._2.asInstanceOf[Some[Int]]) // XXX + // else + // MatchingStrategy.OptionMatchingStrategy.zero; + // if (o7.isEmpty) + // MatchingStrategy.OptionMatchingStrategy.zero + // else + // { + // val o6: Option[Int] = scala.Some.unapply[Int](o7.get); + // if (o6.isEmpty) + // MatchingStrategy.OptionMatchingStrategy.zero + // else + // MatchingStrategy.OptionMatchingStrategy.one[(String, Int)](null.asInstanceOf[(String, Int)]) + // } + // } + // }: Option[(String, Int)]); + // if (o9.isEmpty) + // (MatchingStrategy.OptionMatchingStrategy.zero: Option[(String, Int)]) + // else + // o9 + // }) + // } + // ) + + println(res) +} |