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..c90f59f 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" @@ -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/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..f7f700d 100644 --- a/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala +++ b/odelay-core/src/main/scalajvm/jdk/JdkTimer.scala @@ -32,7 +32,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: Option[JFuture[?]] = try { Some( underlying.schedule( @@ -57,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: Option[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 e645780..e5bd056 100644 --- a/odelay-netty/src/main/scala/NettyTimer.scala +++ b/odelay-netty/src/main/scala/NettyTimer.scala @@ -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: 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: Option[NFuture[_]] = + 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 4c79092..60ae832 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,10 +63,10 @@ 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") + 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)