Skip to content

Avoid unnecessary allocation in Uncancelable trait.#4600

Open
nmichael44 wants to merge 1 commit intotypelevel:series/3.xfrom
nmichael44:optimizeAllocationsInUncancelableTrait
Open

Avoid unnecessary allocation in Uncancelable trait.#4600
nmichael44 wants to merge 1 commit intotypelevel:series/3.xfrom
nmichael44:optimizeAllocationsInUncancelableTrait

Conversation

@nmichael44
Copy link
Copy Markdown
Contributor

Avoid unnecessary allocation in Uncancelable trait for idPoll. We can just allocate it once in object MonadCancel and apply the usual Id Monad trick (as in for example Resource.liftK).

@nmichael44
Copy link
Copy Markdown
Contributor Author

nmichael44 commented May 8, 2026

This fails one of the tests with:

[error] cats-effect-kernel: Failed binary compatibility check against org.typelevel:cats-effect-kernel_3:3.4.10 (e:info.apiURL=https://typelevel.org/cats-effect/api/3.x/, e:info.versionScheme=early-semver)! Found 1 potential problems
[error]  * synthetic static method $init$(cats.effect.kernel.MonadCancel#Uncancelable)Unit in interface cats.effect.kernel.MonadCancel#Uncancelable does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("cats.effect.kernel.MonadCancel#Uncancelable.$init$")
[error] java.lang.RuntimeException: Failed binary compatibility check against org.typelevel:cats-effect-kernel_3:3.4.10 (e:info.apiURL=https://typelevel.org/cats-effect/api/3.x/, e:info.versionScheme=early-semver)! Found 1 potential problems

This happens since there are no longer any fields in the trait and so the Scala compiler eliminates the $init$ method completely. So the new trait is missing a method, and that's why the test complains that the old and new trait definitions are incompatible.

Please advice what the right thing to do is in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant