diff options
author | Stefan Zeiger <szeiger@novocode.com> | 2016-07-13 00:00:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-13 00:00:21 +0200 |
commit | 09d689b8f0ea185077e60d6cf22092dd10da1387 (patch) | |
tree | 3698a11154cb57260e18369b11241d6ea9f2f4b3 /src/compiler | |
parent | ea2f2bf7d3b3e9be76527fb8f660b8b6babe8876 (diff) | |
parent | bd9654d4a22bcccbd98d0f33699ece25f2c0904a (diff) | |
download | scala-09d689b8f0ea185077e60d6cf22092dd10da1387.tar.gz scala-09d689b8f0ea185077e60d6cf22092dd10da1387.tar.bz2 scala-09d689b8f0ea185077e60d6cf22092dd10da1387.zip |
Merge pull request #5135 from soc/topic/biased-either
Right-bias Either
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala b/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala index 4ad4a95728..7b640ac54f 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala @@ -26,9 +26,7 @@ final class BackendReportingImpl(val global: Global) extends BackendReporting { /** * Utilities for error reporting. * - * Defines some tools to make error reporting with Either easier. Would be subsumed by a right-biased - * Either in the standard library (or scalaz \/) (Validation is different, it accumulates multiple - * errors). + * Defines some utility methods to make error reporting with Either easier. */ object BackendReporting { def methodSignature(classInternalName: InternalName, name: String, desc: String) = { @@ -42,19 +40,12 @@ object BackendReporting { def assertionError(message: String): Nothing = throw new AssertionError(message) implicit class RightBiasedEither[A, B](val v: Either[A, B]) extends AnyVal { - def map[C](f: B => C): Either[A, C] = v.right.map(f) - def flatMap[C](f: B => Either[A, C]): Either[A, C] = v.right.flatMap(f) def withFilter(f: B => Boolean)(implicit empty: A): Either[A, B] = v match { case Left(_) => v case Right(e) => if (f(e)) v else Left(empty) // scalaz.\/ requires an implicit Monoid m to get m.empty } - def foreach[U](f: B => U): Unit = v.right.foreach(f) - def getOrElse[C >: B](alt: => C): C = v.right.getOrElse(alt) - - /** - * Get the value, fail with an assertion if this is an error. - */ + /** Get the value, fail with an assertion if this is an error. */ def get: B = { assert(v.isRight, v.left.get) v.right.get |