Skip to content

Commit

Permalink
Fix for empty ZEnvironment
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou committed Aug 5, 2024
1 parent 27baa7a commit 50d9507
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ private[interop] trait ZioSpecBaseLowPriority { self: ZioSpecBase =>
}

implicit def arbitraryZIO[R: Cogen: Tag, E: CanFail: Arbitrary: Cogen, A: Arbitrary: Cogen]: Arbitrary[ZIO[R, E, A]] =
Arbitrary(Gen.function1[ZEnvironment[R], IO[E, A]](arbitraryIO[E, A].arbitrary).map(ZIO.environment[R].flatMap))
Arbitrary(Gen.function1[ZEnvironment[R], IO[E, A]](arbitraryIO[E, A].arbitrary).map { f =>
// TODO: Remove this once it's fixed in ZIO
if (Tag[R] =:= Tag[Any]) f(ZEnvironment(()).asInstanceOf[ZEnvironment[R]])
else ZIO.environment[R].flatMap(f)
})

implicit def arbitraryTask[A: Arbitrary: Cogen](implicit ticker: Ticker): Arbitrary[Task[A]] = {
val arbIO = arbitraryIO[Throwable, A]
Expand Down

0 comments on commit 50d9507

Please sign in to comment.