From bf445098222d8eb2d3a0752012f05c9631ffc9c4 Mon Sep 17 00:00:00 2001 From: Daniel Urban Date: Sat, 17 Feb 2024 07:17:06 +0100 Subject: [PATCH 1/2] Add failing test --- tests/shared/src/test/scala/cats/effect/IOSpec.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/shared/src/test/scala/cats/effect/IOSpec.scala b/tests/shared/src/test/scala/cats/effect/IOSpec.scala index 14d8737021..e8ec582c43 100644 --- a/tests/shared/src/test/scala/cats/effect/IOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/IOSpec.scala @@ -608,6 +608,17 @@ class IOSpec extends BaseSpec with Discipline with IOPlatformSpecification { outerR mustEqual 1 innerR mustEqual 2 } + + "be uncancelable if None finalizer" in ticked { implicit ticker => + val t = IO.asyncCheckAttempt[Int] { _ => IO.pure(Left(None)) } + val test = for { + fib <- t.start + _ <- IO(ticker.ctx.tick()) + _ <- fib.cancel + } yield () + + test must nonTerminate + } } "async" should { From 045b7652d663c9fdc342444c48808457138a3191 Mon Sep 17 00:00:00 2001 From: Daniel Urban Date: Sat, 17 Feb 2024 07:18:24 +0100 Subject: [PATCH 2/2] Make IO#asyncCheckAttempt the same as Async#asyncCheckAttempt --- core/shared/src/main/scala/cats/effect/IO.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/shared/src/main/scala/cats/effect/IO.scala b/core/shared/src/main/scala/cats/effect/IO.scala index 4b91eee1b9..989d405114 100644 --- a/core/shared/src/main/scala/cats/effect/IO.scala +++ b/core/shared/src/main/scala/cats/effect/IO.scala @@ -1206,7 +1206,7 @@ object IO extends IOCompanionPlatform with IOLowPriorityImplicits { lift(k(resume)) flatMap { case Right(a) => G.pure(a) case Left(Some(fin)) => G.onCancel(poll(get), lift(fin)) - case Left(None) => poll(get) + case Left(None) => get } } }