From 50d950794652474736e71574ff6678f85538c570 Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Mon, 5 Aug 2024 16:05:46 +0300 Subject: [PATCH] Fix for empty ZEnvironment --- .../shared/src/test/scala/zio/interop/ZioSpecBase.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zio-interop-cats-tests/shared/src/test/scala/zio/interop/ZioSpecBase.scala b/zio-interop-cats-tests/shared/src/test/scala/zio/interop/ZioSpecBase.scala index 49aaf827..637e6a98 100644 --- a/zio-interop-cats-tests/shared/src/test/scala/zio/interop/ZioSpecBase.scala +++ b/zio-interop-cats-tests/shared/src/test/scala/zio/interop/ZioSpecBase.scala @@ -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]