diff --git a/core/src/main/scala/cats/ApplicativeError.scala b/core/src/main/scala/cats/ApplicativeError.scala index b289782ff8..5b0dc72b08 100644 --- a/core/src/main/scala/cats/ApplicativeError.scala +++ b/core/src/main/scala/cats/ApplicativeError.scala @@ -187,7 +187,7 @@ object ApplicativeError { def apply[F[_], E](implicit F: ApplicativeError[F, E]): ApplicativeError[F, E] = F private[cats] final class LiftFromOptionPartially[F[_]](val dummy: Boolean = true) extends AnyVal { - def apply[E, A](oa: Option[A], ifEmpty: => E)(implicit F: ApplicativeError[F, E]): F[A] = + def apply[E, A](oa: Option[A], ifEmpty: => E)(implicit F: ApplicativeError[F, _ >: E]): F[A] = oa match { case Some(a) => F.pure(a) case None => F.raiseError(ifEmpty) diff --git a/core/src/main/scala/cats/syntax/either.scala b/core/src/main/scala/cats/syntax/either.scala index 78fcfc7863..a59676ac5b 100644 --- a/core/src/main/scala/cats/syntax/either.scala +++ b/core/src/main/scala/cats/syntax/either.scala @@ -277,11 +277,11 @@ final class EitherOps[A, B](val eab: Either[A, B]) extends AnyVal { * scala> import cats.implicits._ * scala> import cats.data.EitherT * scala> val e: Either[String, Int] = Right(3) - * scala> e.liftTo[EitherT[Option, String, ?]] - * res0: cats.data.EitherT[Option, String, Int] = EitherT(Some(Right(3))) + * scala> e.liftTo[EitherT[Option, CharSequence, ?]] + * res0: cats.data.EitherT[Option, CharSequence, Int] = EitherT(Some(Right(3))) * }}} */ - def liftTo[F[_]](implicit F: ApplicativeError[F, A]): F[B] = F.fromEither(eab) + def liftTo[F[_]](implicit F: ApplicativeError[F, _ >: A]): F[B] = F.fromEither(eab) } diff --git a/core/src/main/scala/cats/syntax/option.scala b/core/src/main/scala/cats/syntax/option.scala index 0052aa6cbc..155fee3686 100644 --- a/core/src/main/scala/cats/syntax/option.scala +++ b/core/src/main/scala/cats/syntax/option.scala @@ -178,12 +178,11 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal { * Example: * {{{ * scala> import cats.implicits._ + * scala> Some(1).liftTo[Either[CharSequence, ?]]("Empty") + * res0: scala.Either[CharSequence, Int] = Right(1) * - * scala> Some(1).liftTo[Either[String, ?]]("Empty") - * res0: scala.Either[String, Int] = Right(1) - * - * scala> Option.empty[Int].liftTo[Either[String, ?]]("Empty") - * res1: scala.Either[String, Int] = Left(Empty) + * scala> Option.empty[Int].liftTo[Either[CharSequence, ?]]("Empty") + * res1: scala.Either[CharSequence, Int] = Left(Empty) * }}} */ def liftTo[F[_]]: LiftToPartiallyApplied[F, A] = new LiftToPartiallyApplied(oa) @@ -203,7 +202,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal { object OptionOps { private[syntax] final class LiftToPartiallyApplied[F[_], A](oa: Option[A]) { - def apply[E](ifEmpty: => E)(implicit F: ApplicativeError[F, E]): F[A] = + def apply[E](ifEmpty: => E)(implicit F: ApplicativeError[F, _ >: E]): F[A] = ApplicativeError.liftFromOption(oa, ifEmpty) } }