diff --git a/kyo-core/shared/src/main/scala/kyo/IO.scala b/kyo-core/shared/src/main/scala/kyo/IO.scala index 0eb0f5d2e..35a60482c 100644 --- a/kyo-core/shared/src/main/scala/kyo/IO.scala +++ b/kyo-core/shared/src/main/scala/kyo/IO.scala @@ -87,7 +87,7 @@ object IO: * @throws Throwable * If the evaluation results in an error */ - def evalOrThrow[A: Flat](v: A < (IO & Abort[Throwable]))(using Frame): A = + def evalOrThrow[A: Flat](v: A < (IO & Abort[Throwable]))(using Frame, AllowUnsafe): A = Abort.run(v).eval.getOrThrow /** Runs an IO effect, evaluating it and its side effects. diff --git a/kyo-core/shared/src/test/scala/kyo/IOTest.scala b/kyo-core/shared/src/test/scala/kyo/IOTest.scala index c71d4ad86..87a86b5cc 100644 --- a/kyo-core/shared/src/test/scala/kyo/IOTest.scala +++ b/kyo-core/shared/src/test/scala/kyo/IOTest.scala @@ -135,6 +135,7 @@ class IOTest extends Test: } "evalOrThrow" - { + import AllowUnsafe.embrace.danger "success" in run { val result = IO.Unsafe.evalOrThrow(IO(42)) assert(result == 42) diff --git a/kyo-core/shared/src/test/scala/kyo/Test.scala b/kyo-core/shared/src/test/scala/kyo/Test.scala index b11853ce2..e7887b7ee 100644 --- a/kyo-core/shared/src/test/scala/kyo/Test.scala +++ b/kyo-core/shared/src/test/scala/kyo/Test.scala @@ -16,13 +16,16 @@ abstract class Test extends AsyncFreeSpec with BaseKyoTest[Abort[Any] & Async & def run(v: Future[Assertion] < (Abort[Any] & Async & Resource)): Future[Assertion] = import AllowUnsafe.embrace.danger - val a = Async.run(Abort.run(Resource.run(v)).map(_.fold { - _.getFailure match + v.pipe( + Resource.run, + Abort.recover[Any] { case ex: Throwable => throw ex case e => throw new IllegalStateException(s"Test aborted with $e") - }(identity))) - val b = a.map(_.toFuture).map(_.flatten) - IO.Unsafe.evalOrThrow(b) + }, + Async.run, + _.map(_.toFuture).map(_.flatten), + IO.Unsafe.evalOrThrow + ) end run type Assertion = org.scalatest.compatible.Assertion diff --git a/kyo-stm/shared/src/test/scala/kyo/Test.scala b/kyo-stm/shared/src/test/scala/kyo/Test.scala index b11853ce2..e7887b7ee 100644 --- a/kyo-stm/shared/src/test/scala/kyo/Test.scala +++ b/kyo-stm/shared/src/test/scala/kyo/Test.scala @@ -16,13 +16,16 @@ abstract class Test extends AsyncFreeSpec with BaseKyoTest[Abort[Any] & Async & def run(v: Future[Assertion] < (Abort[Any] & Async & Resource)): Future[Assertion] = import AllowUnsafe.embrace.danger - val a = Async.run(Abort.run(Resource.run(v)).map(_.fold { - _.getFailure match + v.pipe( + Resource.run, + Abort.recover[Any] { case ex: Throwable => throw ex case e => throw new IllegalStateException(s"Test aborted with $e") - }(identity))) - val b = a.map(_.toFuture).map(_.flatten) - IO.Unsafe.evalOrThrow(b) + }, + Async.run, + _.map(_.toFuture).map(_.flatten), + IO.Unsafe.evalOrThrow + ) end run type Assertion = org.scalatest.compatible.Assertion