Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Either#right and Either#left projections #6682

Merged
merged 1 commit into from
Aug 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/library/scala/util/Either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ sealed abstract class Either[+A, +B] extends Product with Serializable {
* for (e <- interactWithDB(someQuery).left) log(s"query failed, reason was $e")
* }}}
*/
@deprecated("use swap instead", "2.13.0")
def left = Either.LeftProjection(this)

/** Projects this `Either` as a `Right`.
*
* Because `Either` is right-biased, this method is not normally needed.
*/
@deprecated("Either is now right-biased", "2.13.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message should explain more directly how users should fix their code.

def right = Either.RightProjection(this)

/** Applies `fa` if this is a `Left` or `fb` if this is a `Right`.
Expand Down Expand Up @@ -476,6 +478,7 @@ object Either {
* @version 1.0, 11/10/2008
* @see [[scala.util.Either#left]]
*/
@deprecated("use swap instead", "2.13.0")
final case class LeftProjection[+A, +B](e: Either[A, B]) {
/** Returns the value from this `Left` or throws `java.util.NoSuchElementException`
* if this is a `Right`.
Expand Down Expand Up @@ -620,6 +623,7 @@ object Either {
* @author <a href="mailto:research@workingmouse.com">Tony Morris</a>, Workingmouse
* @version 1.0, 11/10/2008
*/
@deprecated("Either is now right-biased", "2.13.0")
final case class RightProjection[+A, +B](e: Either[A, B]) {

/** Returns the value from this `Right` or throws
Expand Down