From ad634f351c058fe3e916c11c4a2b8698c7872c8d Mon Sep 17 00:00:00 2001 From: harry0000 Date: Mon, 15 Apr 2024 03:00:20 +0900 Subject: [PATCH] Upgrade to Scala 3.4.1 --- .github/workflows/ci.yaml | 4 ++-- build.sbt | 2 +- src/main/scala/io/github/acl4s/ModInt.scala | 5 ++--- src/main/scala/io/github/acl4s/TwoSAT.scala | 14 ++++++++------ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f0989de..4787848 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,11 +8,11 @@ jobs: fail-fast: false matrix: name: [ "test" ] - scala: [ 3.3.0, 3.3.1 ] + scala: [ 3.3.0, 3.4.1 ] java: [ 20, 21 ] include: - name: "format" - scala: 3.3.1 + scala: 3.4.1 java: 21 exclude: - name: "test" diff --git a/build.sbt b/build.sbt index f62b824..fd8e989 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -lazy val supportedScalaVersions = List("3.3.1", "3.3.0") +lazy val supportedScalaVersions = List("3.4.1", "3.3.0") lazy val root = project .in(file(".")) diff --git a/src/main/scala/io/github/acl4s/ModInt.scala b/src/main/scala/io/github/acl4s/ModInt.scala index 2a1f557..dceb71f 100644 --- a/src/main/scala/io/github/acl4s/ModInt.scala +++ b/src/main/scala/io/github/acl4s/ModInt.scala @@ -90,8 +90,7 @@ object Modulus { inline def apply[T <: Int](): Modulus[T] = Mod(compiletime.constValue[T]) } -final case class StaticModInt[T <: Int] private (private[this] var _value: Int)(using m: Modulus[T]) - extends ModIntBase[T] { +final case class StaticModInt[T <: Int] private (private var _value: Int)(using m: Modulus[T]) extends ModIntBase[T] { override type Self = StaticModInt[T] override val mod: T = m.value @@ -204,7 +203,7 @@ object ModInt998244353 { def apply(value: Long): ModInt998244353 = StaticModInt(value) } -final case class DynamicModInt private (private[this] var _value: Int) extends ModIntBase[Int] { +final case class DynamicModInt private (private var _value: Int) extends ModIntBase[Int] { override type Self = DynamicModInt override val mod: Int = DynamicModInt.bt.m diff --git a/src/main/scala/io/github/acl4s/TwoSAT.scala b/src/main/scala/io/github/acl4s/TwoSAT.scala index 77c2dc6..fde6d63 100644 --- a/src/main/scala/io/github/acl4s/TwoSAT.scala +++ b/src/main/scala/io/github/acl4s/TwoSAT.scala @@ -1,5 +1,7 @@ package io.github.acl4s +import scala.util.boundary, boundary.break + /** * Reference: * B. Aspvall, M. Plass, and R. Tarjan, @@ -28,12 +30,12 @@ class TwoSAT(private val n: Int) { def satisfiable(): Boolean = { val (_, id) = scc.sccIds() - (0 until n).foreach(i => { - if (id(2 * i) == id(2 * i + 1)) { - return false + boundary { + for (i <- 0 until n) { + if (id(2 * i) == id(2 * i + 1)) { break(false) } + answer(i) = id(2 * i) < id(2 * i + 1) } - answer(i) = id(2 * i) < id(2 * i + 1) - }) - true + true + } } }