Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
0e0b3ad
refactor: enforce explicit type annotations, replace unused loop vari…
halotukozak Mar 27, 2026
779ee3e
Merge branch 'series/3.x-avs' into disable-nowarns
halotukozak Mar 27, 2026
fe43c8f
fix: add explicit `Unit` type annotations to ensure consistent type i…
halotukozak Mar 27, 2026
6665e01
refactor: add missing type annotations and mark unused variable in Ta…
halotukozak Mar 27, 2026
044af8d
refactor: add `@unused` annotation to unused variables and enforce ex…
halotukozak Mar 27, 2026
576ebf2
refactor: add `@unused` annotation to unused variables in CircuitBrea…
halotukozak Mar 27, 2026
094a99e
refactor: add `@unused` annotation to unused variables and enforce ex…
halotukozak Mar 30, 2026
da45486
refactor: add `@unused` annotation to unused variables and enforce ex…
halotukozak Mar 30, 2026
4aeadd5
refactor: add `@unused` annotation to unused variables and enforce ex…
halotukozak Mar 30, 2026
b5b960b
refactor: add `@unused` annotations to unused variables in Observable…
halotukozak Mar 30, 2026
8b66920
fix: avoid `@` annotations inside `@define` Scaladoc macros
halotukozak Mar 30, 2026
0b32ecc
refactor: suppress warnings in generated doctest files via -Wconf ins…
halotukozak Mar 30, 2026
bfa11aa
revert: restore Thread.getId calls
halotukozak Mar 30, 2026
b0fb807
fix: suppress deprecated Thread.getId warning via -Wconf
halotukozak Mar 30, 2026
5612a2c
fix: use msg-based -Wconf filters instead of src-based
halotukozak Mar 30, 2026
242efac
fix: remove overly broad discarded non-Unit value suppression from Te…
halotukozak Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -193,32 +193,21 @@ lazy val sharedSettings = pgpSettings ++ Seq(
"-Xlint:infer-any",
"-Wnonunit-statement"
),
// Disabled from tpolecat for test compilation:
// -Wunused:patvars triggers on for-comprehension loop vars in tests (pre-existing pattern)
// -Xlint:constant triggers on intentional overflow tests (e.g. Long.MaxValue + 1)
Test / scalacOptions --= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => Seq("-Wunused:patvars", "-Xlint:constant")
case Some((2, 12)) => Seq("-Ywarn-unused:patvars")
case _ => Seq.empty
}
},
// Turning off fatal warnings for doc generation
Compile / doc / tpolecatExcludeOptions ++= ScalacOptions.defaultConsoleExclude,
// Silence everything in auto-generated files
scalacOptions ++= {
if (isDotty.value)
Seq.empty
Seq("-Wconf:msg=method getId in class Thread is deprecated:s")
else
Seq("-P:silencer:pathFilters=.*[/]src_managed[/].*")
},
scalacOptions --= {
// Disable unused locals check in Test for Scala 3 (generated doctest files trigger false positives)
Test / scalacOptions ++= {
if (isDotty.value)
// tpolecat uses -Werror in Scala 3; disable fatal warnings
// so that pre-existing value-discard and similar patterns don't break Scala 3 builds
Seq("-Werror")
Seq("-Wconf:msg=unused local definition:s")
else
Seq()
Seq.empty
},
// Syntax improvements, linting, etc.
libraryDependencies ++= {
Expand Down
2 changes: 1 addition & 1 deletion monix-eval/shared/src/main/scala/monix/eval/Task.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ sealed abstract class Task[+A] extends Serializable with TaskDeprecated.BinCompa
* var line: String = ""
* while (line != null) {
* line = in.readLine()
* if (line != null) buffer.append(line)
* if (line != null) buffer.append(line): Unit
* }
*
* buffer.toString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private[eval] object TaskConversions {
def run(): Unit = {
if (canCall) {
canCall = false
if (conn ne null) conn.pop()
if (conn ne null) conn.pop(): Unit
cb(value)
value = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private[eval] object TaskCreate {

private def startExecution(): Unit = {
// Cleanup of the current finalizer
if (shouldPop) ctx.connection.pop()
if (shouldPop) ctx.connection.pop(): Unit
// Optimization — if the callback was called on the same thread
// where it was created, then we are not going to fork
// This is not safe to do when localContextPropagation enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private[eval] object TaskFromFuture {
}

def run(): Unit = {
if (conn ne null) conn.pop()
if (conn ne null) conn.pop(): Unit
val v = value
value = null
cb(v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object TaskExecuteWithOptionsSuite extends BaseTestSuite {
val f = task.runToFuture
s.tick()

val Some(Success((opt1, opt2))) = f.value
val Some(Success((opt1, opt2))) = f.value: @unchecked
assert(opt1.localContextPropagation, "opt1.localContextPropagation")
assert(!opt2.localContextPropagation, "!opt2.localContextPropagation")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import monix.execution.Callback
import monix.execution.atomic.{Atomic, AtomicInt}
import monix.execution.exceptions.DummyException
import monix.execution.internal.Platform

import scala.annotation.unused
import scala.util.{Failure, Random, Success, Try}

object TaskFlatMapSuite extends BaseTestSuite {
test("runAsync flatMap loop is not cancelable if autoCancelableRunLoops=false") { implicit s =>
implicit val opts = Task.defaultOptions.disableAutoCancelableRunLoops
implicit val opts: Task.Options = Task.defaultOptions.disableAutoCancelableRunLoops
val maxCount = Platform.recommendedBatchSize * 4

def loop(count: AtomicInt): Task[Unit] =
Expand Down Expand Up @@ -77,7 +79,7 @@ object TaskFlatMapSuite extends BaseTestSuite {
Task.unit.flatMap(_ => loop(count))

val atomic = Atomic(0)
var result = Option.empty[Try[Unit]]
@unused var result = Option.empty[Try[Unit]]

val c = loop(atomic)
.executeWithOptions(_.enableAutoCancelableRunLoops)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.evalAsync(1)
for (i <- 0 until count) task = task.memoizeOnSuccess
for (_ <- 0 until count) task = task.memoizeOnSuccess

val f = task.runToFuture
assertEquals(f.value, None)
Expand All @@ -68,7 +68,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.evalAsync(1)

for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess.flatMap(x => Task.now(x))
}

Expand All @@ -81,7 +81,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.flatMap.memoizeOnSuccess should be stack safe, test 2") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.evalAsync(1)
for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess.flatMap(x => Task.evalAsync(x))
}

Expand Down Expand Up @@ -171,7 +171,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.eval.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.eval(1)
for (i <- 0 until count)
for (_ <- 0 until count)
task = task.memoizeOnSuccess

val f = task.runToFuture; s.tick()
Expand All @@ -181,7 +181,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.eval.flatMap.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.eval(1)
for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess.flatMap(x => Task.eval(x))
}

Expand Down Expand Up @@ -242,7 +242,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.evalOnce.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.eval(1)
for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess
}

Expand All @@ -253,7 +253,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.evalOnce.flatMap.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.eval(1)
for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess.flatMap(x => Task.evalOnce(x))
}

Expand Down Expand Up @@ -297,7 +297,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.now.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.now(1)
for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess
}

Expand All @@ -308,7 +308,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.now.flatMap.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.now(1)
for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess.flatMap(x => Task.now(x))
}

Expand All @@ -321,7 +321,7 @@ object TaskMemoizeOnSuccessSuite extends BaseTestSuite {
test("Task.suspend.memoizeOnSuccess should be stack safe") { implicit s =>
val count = if (Platform.isJVM) 50000 else 5000
var task = Task.defer(Task.now(1))
for (i <- 0 until count) {
for (_ <- 0 until count) {
task = task.memoizeOnSuccess.map(x => x)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private[schedulers] abstract class AdaptedThreadPoolExecutor(corePoolSize: Int,
if ((exception eq null) && r.isInstanceOf[Future[_]]) {
try {
val future = r.asInstanceOf[Future[_]]
if (future.isDone) future.get()
if (future.isDone) future.get(): Unit
} catch {
case ex: ExecutionException =>
exception = ex.getCause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ package monix.execution

import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicLong

import minitest.TestSuite
import monix.execution.FutureUtils.extensions._
import monix.execution.schedulers.TestScheduler

import scala.concurrent.Future
import scala.concurrent.duration._
import scala.reflect.ClassTag

object FutureUtilsJVMSuite extends TestSuite[TestScheduler] {

Expand All @@ -40,6 +40,10 @@ object FutureUtilsJVMSuite extends TestSuite[TestScheduler] {

case class TestException() extends RuntimeException

object TestException {
val ct: ClassTag[TestException] = implicitly[ClassTag[TestException]]
}

val total = new AtomicLong(0)
val sideEffect = new AtomicLong(0)
val error = new AtomicLong(0)
Expand All @@ -64,7 +68,7 @@ object FutureUtilsJVMSuite extends TestSuite[TestScheduler] {
success.incrementAndGet()
()
}.recover {
case _: TestException =>
case TestException.ct(_) =>
error.incrementAndGet()
()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ abstract class ConcurrentAtomicNumberSuite[A, R <: AtomicNumber[A]](

test("should perform concurrent compareAndSet") {
val r = Atomic(ev.zero)
val futures = for (i <- 0 until 5) yield Future {
for (j <- 0 until 100)
val futures = for (_ <- 0 until 5) yield Future {
for (_ <- 0 until 100)
r.increment()
}

Expand All @@ -51,7 +51,7 @@ abstract class ConcurrentAtomicNumberSuite[A, R <: AtomicNumber[A]](

test("should perform concurrent getAndSet") {
val r = Atomic(ev.zero)
val futures = for (i <- 0 until 5) yield Future {
val futures = for (_ <- 0 until 5) yield Future {
for (j <- 0 until 100)
r.getAndSet(ev.fromInt(j + 1))
}
Expand All @@ -63,8 +63,8 @@ abstract class ConcurrentAtomicNumberSuite[A, R <: AtomicNumber[A]](

test("should perform concurrent increment") {
val r = Atomic(ev.zero)
val futures = for (i <- 0 until 5) yield Future {
for (j <- 0 until 100)
val futures = for (_ <- 0 until 5) yield Future {
for (_ <- 0 until 100)
r.increment()
}

Expand All @@ -75,8 +75,8 @@ abstract class ConcurrentAtomicNumberSuite[A, R <: AtomicNumber[A]](

test("should perform concurrent incrementAndGet") {
val r = Atomic(ev.zero)
val futures = for (i <- 0 until 5) yield Future {
for (j <- 0 until 100)
val futures = for (_ <- 0 until 5) yield Future {
for (_ <- 0 until 100)
r.incrementAndGet()
}

Expand All @@ -87,8 +87,8 @@ abstract class ConcurrentAtomicNumberSuite[A, R <: AtomicNumber[A]](

test("should perform concurrent getAndIncrement") {
val r = Atomic(ev.zero)
val futures = for (i <- 0 until 5) yield Future {
for (j <- 0 until 100)
val futures = for (_ <- 0 until 5) yield Future {
for (_ <- 0 until 100)
r.getAndIncrement()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ abstract class ConcurrentAtomicSuite[A, R <: Atomic[A]](

test("should perform concurrent compareAndSet") {
val r = Atomic(zero)
val futures = for (i <- 0 until 5) yield Future {
for (j <- 0 until 100)
val futures = for (_ <- 0 until 5) yield Future {
for (_ <- 0 until 100)
r.transform(x => valueFromInt(valueToInt(x) + 1))
}

Expand All @@ -50,7 +50,7 @@ abstract class ConcurrentAtomicSuite[A, R <: Atomic[A]](

test("should perform concurrent getAndSet") {
val r = Atomic(zero)
val futures = for (i <- 0 until 5) yield Future {
val futures = for (_ <- 0 until 5) yield Future {
for (j <- 0 until 100)
r.getAndSet(valueFromInt(j))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ object Ack {
*/
def syncOnContinueFollow[A](p: Promise[A], value: A): Self = {
if (source eq Continue)
p.trySuccess(value)
p.trySuccess(value): Unit
else if (source ne Stop)
source.onComplete { r =>
if (r.isSuccess && (r.get eq Continue))
p.trySuccess(value)
p.trySuccess(value): Unit
}(immediate)
source
}
Expand All @@ -227,11 +227,11 @@ object Ack {
*/
def syncOnStopFollow[A](p: Promise[A], value: A): Self = {
if (source eq Stop)
p.trySuccess(value)
p.trySuccess(value): Unit
else if (source ne Continue)
source.onComplete { r =>
if (r.isSuccess && (r.get eq Stop))
p.trySuccess(value)
p.trySuccess(value): Unit
}(immediate)
source
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ sealed abstract class CancelableFuture[+A] extends Future[A] with Cancelable { s
override final def andThen[U](pf: PartialFunction[Try[A], U])(implicit
executor: ExecutionContext): CancelableFuture[A] =
transformWith { r =>
if (pf.isDefinedAt(r)) pf(r)
if (pf.isDefinedAt(r)) pf(r): Unit
this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ object CancelablePromise {
}
if (errors ne null) {
// Throws all errors as a composite
val x :: xs = errors.toList
val x :: xs = errors.toList: @unchecked
throw Platform.composeErrors(x, xs: _*)
}
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object CancelableSuite extends SimpleTestSuite {
assertEquals(e, dummy1)
assertEquals(e.getSuppressed.toList, List(dummy2))
} else {
val CompositeException(errors) = e
val CompositeException(errors) = e: @unchecked
assertEquals(errors.toList, List(dummy1, dummy2))
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ object CancelableSuite extends SimpleTestSuite {
assertEquals(e, dummy1)
assertEquals(e.getSuppressed.toList, List(dummy2))
} else {
val CompositeException(errors) = sc.state.lastReportedError
val CompositeException(errors) = sc.state.lastReportedError: @unchecked
assertEquals(errors.toList, List(dummy1, dummy2))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ object OrderedCancelableSuite extends SimpleTestSuite {
val c2 = Cancelable { () =>
effect = 2
}
mc.orderedUpdate(c2, Long.MaxValue + 1)
mc.orderedUpdate(c2, Long.MinValue)
val c3 = Cancelable { () =>
effect = 3
}
mc.orderedUpdate(c3, Long.MaxValue + 2)
mc.orderedUpdate(c3, Long.MinValue + 1)
val c4 = Cancelable { () =>
effect = 4
}
Expand Down
Loading
Loading