Skip to content

Make resourceScope callable from Scala 3.9 - #513

Merged
adamw merged 1 commit into
masterfrom
fix-scala39-unit-erasure
Sep 23, 2026
Merged

adamw merged 1 commit into
masterfrom
fix-scala39-unit-erasure

Conversation

@adamw

@adamw adamw commented Sep 23, 2026

Copy link
Copy Markdown
Member

Code compiled with Scala 3.9 fails when calling resourceScope:

java.lang.NoSuchMethodError: 'void ox.resource$package$NoEnclosingConcurrencyScope$.noEnclosingConcurrencyScope(scala.util.NotGiven)'

Scala 3.9 compiles a method whose result is an alias of Unit to return void. Ox is built with 3.3, which compiles it to return BoxedUnit. See scala/scala3#24653.

The fix uses the workaround from that issue: NoEnclosingConcurrencyScope now extends a trait that declares the same method with a Unit result, so the compiler emits both versions. Tested with resourceScope(42) compiled with Scala 3.3.8, 3.9.0 and the current nightly. MiMa passes.

@adamw
adamw merged commit 7f14d43 into master Sep 23, 2026
6 checks passed
@adamw
adamw deleted the fix-scala39-unit-erasure branch September 23, 2026 08:16
adamw added a commit to VirtusLab/orca that referenced this pull request Sep 23, 2026
Removes the `onRoleResolved` callback and the `roles`/`transferred` vars
from `buildContext`. Agents are now closed by one Ox `resourceScope`
that covers building the context and running the flow.

Needs Ox 1.0.8: earlier versions fail with `NoSuchMethodError` when
`resourceScope` is called from Scala 3.9 (scala/scala3#24653, fixed in
softwaremill/ox#513).
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