diff --git a/core/src/main/scala/cats/data/Xor.scala b/core/src/main/scala/cats/data/Xor.scala index 083d4fbd51d..21e1231752e 100644 --- a/core/src/main/scala/cats/data/Xor.scala +++ b/core/src/main/scala/cats/data/Xor.scala @@ -38,8 +38,8 @@ sealed abstract class Xor[+A, +B] extends Product with Serializable { def getOrElse[BB >: B](default: => BB): BB = fold(_ => default, identity) - def orElse[AA >: A, BB >: B](fallback: => AA Xor BB): AA Xor BB = - fold(_ => fallback, _ => this) + def orElse[C, BB >: B](fallback: => C Xor BB): C Xor BB = + fold(_ => fallback, a => Xor.Right(a)) def recover[BB >: B](pf: PartialFunction[A, BB]): A Xor BB = this match { case Xor.Left(a) if pf.isDefinedAt(a) => Xor.right(pf(a))