From a5d5eacecfe3f53ee6df5196cf1008413d543f06 Mon Sep 17 00:00:00 2001 From: pierscin <30854591+pierscin@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:58:47 +0200 Subject: [PATCH 1/3] Migrate to Scala 3.9.0 LTS Co-Authored-By: Claude Opus 5.5 --- .scala-steward.conf | 4 ++-- build.sbt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.scala-steward.conf b/.scala-steward.conf index 391fa4f..5125b3c 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -1,5 +1,5 @@ updates.pin = [ - {groupId = "org.scala-lang", artifactId = "scala3-library", version = "3.3."}, - {groupId = "org.scala-lang", artifactId = "scala3-library_sjs1", version = "3.3."}, + {groupId = "org.scala-lang", artifactId = "scala3-library", version = "3.9."}, + {groupId = "org.scala-lang", artifactId = "scala3-library_sjs1", version = "3.9."}, {groupId = "org.scala-lang", artifactId = "scala-library", version = "2.13."} ] diff --git a/build.sbt b/build.sbt index 0ce1560..2493b4c 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ import com.softwaremill.Publish.ossPublishSettings val scala2_12 = "2.12.19" val scala2_13 = "2.13.18" val scala2 = List(scala2_12, scala2_13) -val scala3 = List("3.3.3") +val scala3 = List("3.9.0") val scalatestVersion = "3.2.19" From 5863bda0c9f5f8af73754d89886542d3b545ac49 Mon Sep 17 00:00:00 2001 From: pierscin <30854591+pierscin@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:58:47 +0200 Subject: [PATCH 2/3] Fix new Scala 3.9 warnings Co-Authored-By: Claude Opus 5.5 --- odelay-core/src/main/scalajs/JsTimer.scala | 1 + odelay-core/src/main/scalajvm/jdk/JdkTimer.scala | 5 ++--- odelay-netty/src/main/scala/NettyTimer.scala | 6 +++--- odelay-testing/src/test/scalajs/TimerSpec.scala | 4 ++-- odelay-testing/src/test/scalajvm/TimerSpec.scala | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/odelay-core/src/main/scalajs/JsTimer.scala b/odelay-core/src/main/scalajs/JsTimer.scala index 6d813c8..1edb3e2 100644 --- a/odelay-core/src/main/scalajs/JsTimer.scala +++ b/odelay-core/src/main/scalajs/JsTimer.scala @@ -31,6 +31,7 @@ class JsTimer() extends Timer { } def cancel(): Unit = { + clearTimeout(initclearable) if (clearable != null) clearInterval(clearable) cancelPromise() } diff --git a/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala b/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala index 55cb216..41b092d 100644 --- a/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala +++ b/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala @@ -1,7 +1,6 @@ package odelay.jdk import java.util.concurrent.{ - Future => JFuture, RejectedExecutionHandler, ScheduledExecutorService, ScheduledThreadPoolExecutor, @@ -32,7 +31,7 @@ class JdkTimer(underlying: ScheduledExecutorService, interruptOnCancel: Boolean) def apply[T](delay: FiniteDuration, op: => T): Delay[T] = new PromisingDelay[T] { - val jfuture: Option[JFuture[_]] = + val jfuture = try { Some( underlying.schedule( @@ -57,7 +56,7 @@ class JdkTimer(underlying: ScheduledExecutorService, interruptOnCancel: Boolean) def apply[T](delay: FiniteDuration, every: FiniteDuration, op: => T): PeriodicDelay[T] = new PeriodicPromisingDelay[T](every) { - val jfuture: Option[JFuture[_]] = + val jfuture = try { Some( underlying.scheduleWithFixedDelay( diff --git a/odelay-netty/src/main/scala/NettyTimer.scala b/odelay-netty/src/main/scala/NettyTimer.scala index e645780..0e6034f 100644 --- a/odelay-netty/src/main/scala/NettyTimer.scala +++ b/odelay-netty/src/main/scala/NettyTimer.scala @@ -1,7 +1,7 @@ package odelay.netty import io.netty.util.{HashedWheelTimer, Timeout, Timer => NTimer, TimerTask} -import io.netty.util.concurrent.{EventExecutorGroup, Future => NFuture} +import io.netty.util.concurrent.EventExecutorGroup import odelay.{Delay, PeriodicDelay, PeriodicPromisingDelay, PromisingDelay, Timer} import odelay.jdk.JdkTimer import java.util.concurrent.TimeUnit @@ -13,7 +13,7 @@ class NettyGroupTimer(grp: EventExecutorGroup, interruptOnCancel: Boolean = Nett def apply[T](delay: FiniteDuration, op: => T): Delay[T] = new PromisingDelay[T] { - val sf: Option[NFuture[_]] = + val sf = try { Some( grp.schedule( @@ -38,7 +38,7 @@ class NettyGroupTimer(grp: EventExecutorGroup, interruptOnCancel: Boolean = Nett def apply[T](delay: FiniteDuration, every: FiniteDuration, op: => T): PeriodicDelay[T] = new PeriodicPromisingDelay[T](every) { - val sf: Option[NFuture[_]] = + val sf = try { Some( grp.scheduleWithFixedDelay( diff --git a/odelay-testing/src/test/scalajs/TimerSpec.scala b/odelay-testing/src/test/scalajs/TimerSpec.scala index 4c79092..8e51f61 100644 --- a/odelay-testing/src/test/scalajs/TimerSpec.scala +++ b/odelay-testing/src/test/scalajs/TimerSpec.scala @@ -46,7 +46,7 @@ class TimerSpec extends AsyncFunSpec with BeforeAndAfterAll { cancel.cancel() } cancel.future.recover { - case x: CancellationException => succeed + case _: CancellationException => succeed case _ => fail() } } @@ -63,7 +63,7 @@ class TimerSpec extends AsyncFunSpec with BeforeAndAfterAll { it("successful completion of delayed operations should result in a future failure") { case object CustomException extends Exception - val future = Delay(1.second)(throw CustomException).future + val future = Delay[Unit](1.second)(throw CustomException).future future.transformWith { case Failure(exception) => assert(exception === CustomException) case _ => fail("The delayed future was expected to fail") diff --git a/odelay-testing/src/test/scalajvm/TimerSpec.scala b/odelay-testing/src/test/scalajvm/TimerSpec.scala index fe3ef2f..ebd084c 100644 --- a/odelay-testing/src/test/scalajvm/TimerSpec.scala +++ b/odelay-testing/src/test/scalajvm/TimerSpec.scala @@ -39,7 +39,7 @@ trait TimerSpec extends AsyncFunSpec with BeforeAndAfterAll { cancel.cancel() } for { - cf <- cancelF.future + _ <- cancelF.future c <- cancel.future.failed } yield { assert(c.getClass === classOf[CancellationException]) @@ -54,7 +54,7 @@ trait TimerSpec extends AsyncFunSpec with BeforeAndAfterAll { it("unsuccessful completion of delayed operations should result in a future failure") { case object CustomException extends Exception - val future = Delay(1.second)(throw CustomException).future + val future = Delay[Unit](1.second)(throw CustomException).future future.transformWith { case Failure(exception) => assert(exception === CustomException) case _ => fail("The delayed future was expected to fail") @@ -78,7 +78,7 @@ trait TimerSpec extends AsyncFunSpec with BeforeAndAfterAll { val counter = new AtomicInteger(0) val cancel = Delay.every(150.seconds)()(true) val cancelFut = cancel.future.recoverWith { - case e: CancellationException => + case _: CancellationException => counter.incrementAndGet() Future.successful(true) case _ => Future.successful(true) From bd3c984e00031709f63279969724c7e0ad01ebf9 Mon Sep 17 00:00:00 2001 From: pierscin <30854591+pierscin@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:08:16 +0200 Subject: [PATCH 3/3] Use ? wildcards instead of inferred types Enable -Xsource:3 in the Scala 2 builds, so the shared sources can use `?`. Co-Authored-By: Claude Opus 5.5 --- build.sbt | 3 ++- odelay-core/src/main/scalajvm/jdk/JdkTimer.scala | 5 +++-- odelay-netty/src/main/scala/NettyTimer.scala | 6 +++--- odelay-netty/src/test/scala/NettyGroupTimerSpec.scala | 2 +- odelay-testing/src/test/scalajs/TimerSpec.scala | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 2493b4c..c90f59f 100644 --- a/build.sbt +++ b/build.sbt @@ -17,7 +17,8 @@ organization := "com.softwaremill.odelay" licenses := Seq(License("MIT", url(s"https://github.com/softprops/odelay/blob/${version.value}/LICENSE"))) val commonJvmSettings = Seq( - scalacOptions ++= (if (ScalaArtifacts.isScala3(scalaVersion.value)) Seq.empty else Seq("-release", "8")), + scalacOptions ++= (if (ScalaArtifacts.isScala3(scalaVersion.value)) Seq.empty + else Seq("-release", "8", "-Xsource:3")), ideSkipProject := (scalaVersion.value != scala2_13) ) diff --git a/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala b/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala index 41b092d..f7f700d 100644 --- a/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala +++ b/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala @@ -1,6 +1,7 @@ package odelay.jdk import java.util.concurrent.{ + Future => JFuture, RejectedExecutionHandler, ScheduledExecutorService, ScheduledThreadPoolExecutor, @@ -31,7 +32,7 @@ class JdkTimer(underlying: ScheduledExecutorService, interruptOnCancel: Boolean) def apply[T](delay: FiniteDuration, op: => T): Delay[T] = new PromisingDelay[T] { - val jfuture = + val jfuture: Option[JFuture[?]] = try { Some( underlying.schedule( @@ -56,7 +57,7 @@ class JdkTimer(underlying: ScheduledExecutorService, interruptOnCancel: Boolean) def apply[T](delay: FiniteDuration, every: FiniteDuration, op: => T): PeriodicDelay[T] = new PeriodicPromisingDelay[T](every) { - val jfuture = + val jfuture: Option[JFuture[?]] = try { Some( underlying.scheduleWithFixedDelay( diff --git a/odelay-netty/src/main/scala/NettyTimer.scala b/odelay-netty/src/main/scala/NettyTimer.scala index 0e6034f..e5bd056 100644 --- a/odelay-netty/src/main/scala/NettyTimer.scala +++ b/odelay-netty/src/main/scala/NettyTimer.scala @@ -1,7 +1,7 @@ package odelay.netty import io.netty.util.{HashedWheelTimer, Timeout, Timer => NTimer, TimerTask} -import io.netty.util.concurrent.EventExecutorGroup +import io.netty.util.concurrent.{EventExecutorGroup, Future => NFuture} import odelay.{Delay, PeriodicDelay, PeriodicPromisingDelay, PromisingDelay, Timer} import odelay.jdk.JdkTimer import java.util.concurrent.TimeUnit @@ -13,7 +13,7 @@ class NettyGroupTimer(grp: EventExecutorGroup, interruptOnCancel: Boolean = Nett def apply[T](delay: FiniteDuration, op: => T): Delay[T] = new PromisingDelay[T] { - val sf = + val sf: Option[NFuture[?]] = try { Some( grp.schedule( @@ -38,7 +38,7 @@ class NettyGroupTimer(grp: EventExecutorGroup, interruptOnCancel: Boolean = Nett def apply[T](delay: FiniteDuration, every: FiniteDuration, op: => T): PeriodicDelay[T] = new PeriodicPromisingDelay[T](every) { - val sf = + val sf: Option[NFuture[?]] = try { Some( grp.scheduleWithFixedDelay( diff --git a/odelay-netty/src/test/scala/NettyGroupTimerSpec.scala b/odelay-netty/src/test/scala/NettyGroupTimerSpec.scala index 48e0816..d47dc39 100644 --- a/odelay-netty/src/test/scala/NettyGroupTimerSpec.scala +++ b/odelay-netty/src/test/scala/NettyGroupTimerSpec.scala @@ -3,6 +3,6 @@ package odelay.netty import io.netty.util.concurrent.DefaultEventExecutorGroup class NettyGroupTimerSpec extends odelay.testing.TimerSpec { - def newTimer = NettyTimer.groupTimer(new DefaultEventExecutorGroup(1)) + def newTimer: odelay.Timer = NettyTimer.groupTimer(new DefaultEventExecutorGroup(1)) def timerName = "NettyGroupTimer" } diff --git a/odelay-testing/src/test/scalajs/TimerSpec.scala b/odelay-testing/src/test/scalajs/TimerSpec.scala index 8e51f61..60ae832 100644 --- a/odelay-testing/src/test/scalajs/TimerSpec.scala +++ b/odelay-testing/src/test/scalajs/TimerSpec.scala @@ -66,7 +66,7 @@ class TimerSpec extends AsyncFunSpec with BeforeAndAfterAll { val future = Delay[Unit](1.second)(throw CustomException).future future.transformWith { case Failure(exception) => assert(exception === CustomException) - case _ => fail("The delayed future was expected to fail") + case _ => fail("The delayed future was expected to fail") } }