Skip to content

Commit

Permalink
ZValidation#orElse and ZValidation#orElseLog parameter must be la…
Browse files Browse the repository at this point in the history
…zy (#1356)
  • Loading branch information
guizmaii authored Aug 14, 2024
1 parent a1af527 commit ad88db1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/zio/prelude/ZValidation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ sealed trait ZValidation[+W, +E, +A] { self =>
case Success(w, a) => (w, Right(a))
}

final def orElse[W1 >: W, E1, A1 >: A](that: ZValidation[W1, E1, A1]): ZValidation[W1, E1, A1] =
final def orElse[W1 >: W, E1, A1 >: A](that: => ZValidation[W1, E1, A1]): ZValidation[W1, E1, A1] =
self match {
case Failure(log, _) => that.mapLogAll(log ++ _)
case success: Success[_, _] => success
}

final def orElseLog[W1 >: W, E1, A1 >: A](
that: ZValidation[W1, E1, A1]
that: => ZValidation[W1, E1, A1]
)(implicit ev: E <:< W1): ZValidation[W1, E1, A1] =
self match {
case Failure(log, errors) => that.mapLogAll(log ++ errors.map(ev) ++ _)
Expand Down

0 comments on commit ad88db1

Please sign in to comment.