From 9fc99edd4d2ddd150d394290774fde941f203cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Mon, 1 Jun 2026 15:26:23 +0200 Subject: [PATCH 1/2] chore(core): drop deprecated Sam and SamCompanion - Delete core/src/main/scala/com/avsystem/commons/misc/Sam.scala (@deprecated since 2.28.0) - Delete core/src/main/scala/com/avsystem/commons/misc/SamCompanion.scala (@deprecated since 2.28.0) - Delete corresponding test SamTest.scala - Stdlib native SAM conversion (Scala 2.12+) supersedes; no Scala 3 port per project rule feedback_dont_port_deprecated.md - Zero non-self references in core/, mongo/, hocon/ --- .../scala/com/avsystem/commons/misc/Sam.scala | 11 -- .../avsystem/commons/misc/SamCompanion.scala | 22 ---- .../com/avsystem/commons/misc/SamTest.scala | 107 ------------------ 3 files changed, 140 deletions(-) delete mode 100644 core/src/main/scala/com/avsystem/commons/misc/Sam.scala delete mode 100644 core/src/main/scala/com/avsystem/commons/misc/SamCompanion.scala delete mode 100644 core/src/test/scala/com/avsystem/commons/misc/SamTest.scala diff --git a/core/src/main/scala/com/avsystem/commons/misc/Sam.scala b/core/src/main/scala/com/avsystem/commons/misc/Sam.scala deleted file mode 100644 index 3705aa811..000000000 --- a/core/src/main/scala/com/avsystem/commons/misc/Sam.scala +++ /dev/null @@ -1,11 +0,0 @@ -package com.avsystem.commons -package misc - -@deprecated( - "Use native SAM conversion instead, e.g. `val r: Runnable = () => doStuff()` or `val c: JConsumer[T] = t => ...`", - "2.28.0", -) -object Sam { - // TODO[scala3-port]: Sam.apply (Scala 2 macro def) (L) - def apply[T](fun: => Any): T = ??? -} diff --git a/core/src/main/scala/com/avsystem/commons/misc/SamCompanion.scala b/core/src/main/scala/com/avsystem/commons/misc/SamCompanion.scala deleted file mode 100644 index 5af10fb82..000000000 --- a/core/src/main/scala/com/avsystem/commons/misc/SamCompanion.scala +++ /dev/null @@ -1,22 +0,0 @@ -package com.avsystem.commons -package misc - -import com.avsystem.commons.misc.SamCompanion.ValidSam - -@deprecated( - "Use native SAM conversion instead, e.g. `val r: Runnable = () => doStuff()` or `val c: JConsumer[T] = t => ...`", - "2.28.0", -) -abstract class SamCompanion[T, F](implicit vs: ValidSam[T, F]) { - // TODO[scala3-port]: SamCompanion.apply (Scala 2 macro def) (L) - def apply(fun: F): T = ??? -} - -object SamCompanion { - sealed trait ValidSam[T, F] - - object ValidSam { - // TODO[scala3-port]: isValidSam (Scala 2 macro def) (L) - implicit def isValidSam[T, F]: ValidSam[T, F] = ??? - } -} diff --git a/core/src/test/scala/com/avsystem/commons/misc/SamTest.scala b/core/src/test/scala/com/avsystem/commons/misc/SamTest.scala deleted file mode 100644 index 464543ddd..000000000 --- a/core/src/test/scala/com/avsystem/commons/misc/SamTest.scala +++ /dev/null @@ -1,107 +0,0 @@ -package com.avsystem.commons -package misc - -import org.scalatest.funsuite.AnyFunSuite - -import scala.annotation.nowarn - -@nowarn("msg=deprecated") -class SamTest extends AnyFunSuite { - - test("no arg lists by name") { - trait NoArgListsSam { - def handle: String - } - object NoArgListsSam extends SamCompanion[NoArgListsSam, String] - - val sam = NoArgListsSam("42") - assert(sam.handle == "42") - - val adhoc = Sam[NoArgListsSam]("42") - assert(adhoc.handle == "42") - } - - test("no args") { - trait NoArgSam { - def handle(): String - } - object NoArgSam extends SamCompanion[NoArgSam, () => String] - - val sam = NoArgSam(() => "42") - assert(sam.handle() == "42") - - val adhoc = Sam[NoArgSam](() => "42") - assert(adhoc.handle() == "42") - } - - test("no args by name") { - trait NoArgSam { - def handle(): String - } - object NoArgSam extends SamCompanion[NoArgSam, String] - - @nowarn - val sam = NoArgSam("42") - assert(sam.handle() == "42") - - @nowarn - val adhoc = Sam[NoArgSam]("42") - assert(adhoc.handle() == "42") - } - - test("single arg") { - trait SingleArgSam { - def handle(i: Int): String - } - object SingleArgSam extends SamCompanion[SingleArgSam, Int => String] - - val sam = SingleArgSam(_.toString) - assert(sam.handle(123) == "123") - - val adhoc = Sam[SingleArgSam]((_: Int).toString) - assert(adhoc.handle(123) == "123") - } - - test("two args") { - trait TwoArgSam { - def handle(i: Int, str: String): String - } - object TwoArgSam extends SamCompanion[TwoArgSam, (Int, String) => String] - - val sam = TwoArgSam(_.toString + _) - assert(sam.handle(123, "lol") == "123lol") - - val adhoc = Sam[TwoArgSam]((i: Int, s: String) => i.toString + s) - assert(adhoc.handle(123, "lol") == "123lol") - } - - test("multiple arg lists") { - trait MultipleArgListsSam { - def handle(i: Int)(str: String): String - } - object MultipleArgListsSam extends SamCompanion[MultipleArgListsSam, Int => String => String] - - val fullSam = MultipleArgListsSam(i => s => i.toString + s) - assert(fullSam.handle(123)("lol") == "123lol") - - def ptApplied(i: Int) = (s: String) => i.toString + s - val partialSam = MultipleArgListsSam(i => ptApplied(i)) - assert(partialSam.handle(123)("lol") == "123lol") - - val adhoc = Sam[MultipleArgListsSam]((i: Int) => (s: String) => i.toString + s) - assert(adhoc.handle(123)("lol") == "123lol") - } - - test("implicit params") { - trait ImplicitParamsSam { - def handle(i: Int)(implicit str: String): String - } - object ImplicitParamsSam extends SamCompanion[ImplicitParamsSam, Int => String => String] - - val sam = ImplicitParamsSam(i => s => i.toString + s) - assert(sam.handle(123)("lol") == "123lol") - - val adhoc = Sam[ImplicitParamsSam]((i: Int) => (s: String) => i.toString + s) - assert(adhoc.handle(123)("lol") == "123lol") - } -} From cf950183d0442a5daab07502388c5fcbecb0eae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Mon, 1 Jun 2026 15:28:27 +0200 Subject: [PATCH 2/2] docs(migration): record Sam/SamCompanion as will-not-migrate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add §1 (Will Not Migrate) row for misc.Sam / misc.SamCompanion - Remove §6 Backlog rows for Sam.scala:9, SamCompanion.scala:11, SamCompanion.scala:19 - Decrement Total tags: 155 -> 153 --- MIGRATION.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index b99395701..b051791dd 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -18,6 +18,7 @@ the bottom of this file. Restoration ships incrementally per feature area. | `-Wconf` warning suppression blocks | Project rule: fix warnings at source, not via suppression. | | `-language:experimental.macros` | Scala 3 uses `inline` + `scala.quoted`; flag is a no-op. | | Scala 2 macro impls (`c.universe`, blackbox/whitebox) | Replaced by Scala 3 quotes/inline during feature-area restoration; the legacy `commons-macros` module is gone. | +| `misc.Sam` / `misc.SamCompanion` | `@deprecated since 2.28.0`; stdlib native SAM conversion replaces it. Per rule `feedback_dont_port_deprecated.md`: skip @deprecated APIs with stdlib replacements. Phase 2 slice 02-05. | ## 2. Deprecated on Scala 3 @@ -107,7 +108,7 @@ Full per-file list with locations is in the Backlog table below (filter rows whe ## Backlog -*Auto-derived from `git grep -nE 'TODO\[scala3-port\]'` on this PR's tip. Total tags: 155.* +*Auto-derived from `git grep -nE 'TODO\[scala3-port\]'` on this PR's tip. Total tags: 153.* | Location | Description | Effort | |---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|--------| @@ -164,9 +165,6 @@ Full per-file list with locations is in the Backlog table below (filter rows whe | `core/src/main/scala/com/avsystem/commons/misc/Implicits.scala:5` | infer (Scala 2 macro def) | L | | `core/src/main/scala/com/avsystem/commons/misc/Implicits.scala:7` | infer(clue) (Scala 2 macro def) | L | | `core/src/main/scala/com/avsystem/commons/misc/Implicits.scala:9` | inferNonMacro (Scala 2 macro def) | L | -| `core/src/main/scala/com/avsystem/commons/misc/Sam.scala:9` | Sam.apply (Scala 2 macro def) | L | -| `core/src/main/scala/com/avsystem/commons/misc/SamCompanion.scala:11` | SamCompanion.apply (Scala 2 macro def) | L | -| `core/src/main/scala/com/avsystem/commons/misc/SamCompanion.scala:19` | isValidSam (Scala 2 macro def) | L | | `core/src/main/scala/com/avsystem/commons/misc/SealedUtils.scala:12` | instancesFor (Scala 2 macro def; return type widened to TC[T]) | L | | `core/src/main/scala/com/avsystem/commons/misc/SealedUtils.scala:52` | caseObjects (Scala 2 macro def) | L | | `core/src/main/scala/com/avsystem/commons/misc/SealedUtils.scala:8` | caseObjectsFor (Scala 2 macro def) | L |