From e744e35def0b3dbbf9be52310e9957eb301d455a Mon Sep 17 00:00:00 2001 From: Adam Warski Date: Wed, 23 Sep 2026 08:09:53 +0000 Subject: [PATCH] Make resourceScope callable from Scala 3.9 --- core/src/main/scala/ox/resource.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/ox/resource.scala b/core/src/main/scala/ox/resource.scala index 705552eb..82f36c8f 100644 --- a/core/src/main/scala/ox/resource.scala +++ b/core/src/main/scala/ox/resource.scala @@ -11,7 +11,13 @@ import scala.util.NotGiven ) opaque type NoEnclosingConcurrencyScope = Unit -object NoEnclosingConcurrencyScope: +/** Scala 3.9+ erases a result of type `NoEnclosingConcurrencyScope` to `void`, earlier versions to `BoxedUnit`. Overriding this method + * makes the compiler emit both signatures, so code compiled with 3.9+ links against Ox (https://github.com/scala/scala3/issues/24653). + */ +private[ox] trait NoEnclosingConcurrencyScopeVoidErasure: + def noEnclosingConcurrencyScope(using NotGiven[OxUnsupervised]): Unit + +object NoEnclosingConcurrencyScope extends NoEnclosingConcurrencyScopeVoidErasure: // in the companion, so that it's found via the implicit scope of the type, without any imports given noEnclosingConcurrencyScope(using NotGiven[OxUnsupervised]): NoEnclosingConcurrencyScope = ()