diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-14 22:21:51 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-14 23:27:05 +0100 |
commit | 9bf58090c704a59d8735874c565200758bcea666 (patch) | |
tree | 705c77dc8cea85ecf0203ea710957542541c4bb5 /tests/pos/i1790.scala | |
parent | ba06bf06721f1a8de7d68d22ad7eba27fff90c43 (diff) | |
download | dotty-9bf58090c704a59d8735874c565200758bcea666.tar.gz dotty-9bf58090c704a59d8735874c565200758bcea666.tar.bz2 dotty-9bf58090c704a59d8735874c565200758bcea666.zip |
Change by-name pattern matching.
New implementation following the scheme outlined in #1790.
Diffstat (limited to 'tests/pos/i1790.scala')
-rw-r--r-- | tests/pos/i1790.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/pos/i1790.scala b/tests/pos/i1790.scala new file mode 100644 index 000000000..7535255f9 --- /dev/null +++ b/tests/pos/i1790.scala @@ -0,0 +1,15 @@ +import scala.util.control.NonFatal + +class Try[+T] { + def transform[U](s: T => Try[U], f: Throwable => Try[U]): Try[U] = + try this match { + case Success(v) => s(v) + case Failure(e) => f(e) + } catch { + case NonFatal(e) => Failure(e) + } +} +final case class Success[+T](value: T) extends Try[T] +final case class Failure[+T](exception: Throwable) extends Try[T] { + def get: T = throw exception +} |