diff --git a/MIGRATION.md b/MIGRATION.md index b99395701..7ff2b7b1c 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -7,17 +7,19 @@ the bottom of this file. Restoration ships incrementally per feature area. ## 1. Will not migrate -| Symbol/module | Rationale | -|-------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `commons-macros` module | Pure Scala 2 macro infrastructure (`c.universe`, blackbox/whitebox). No Scala 3 surface worth porting; Scala 3 uses inline + quotes which is a structural redesign. Module deleted outright in Phase 1. | -| `analyzer` module | Scala 2 compiler plugin; would require a full Scala 3 compiler plugin rewrite. Restored only if downstream demand surfaces. | -| `jetty` module | ee10 servlet wrapper; deprecated upstream. Out of scope until/unless restored. | -| `spring` module | spring-context wiring; deprecated upstream. Module deleted outright in Phase 1. | -| `comprof` module | `scalac-profiling` plugin is Scala 2 only. Retire pending a Scala 3 alternative. | -| `-Xsource:3` scalac flag | Obsolete — the codebase IS Scala 3 now. | -| `-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. | +| Symbol/module | Rationale | +|-----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `commons-macros` module | Pure Scala 2 macro infrastructure (`c.universe`, blackbox/whitebox). No Scala 3 surface worth porting; Scala 3 uses inline + quotes which is a structural redesign. Module deleted outright in Phase 1. | +| `analyzer` module | Scala 2 compiler plugin; would require a full Scala 3 compiler plugin rewrite. Restored only if downstream demand surfaces. | +| `jetty` module | ee10 servlet wrapper; deprecated upstream. Out of scope until/unless restored. | +| `spring` module | spring-context wiring; deprecated upstream. Module deleted outright in Phase 1. | +| `comprof` module | `scalac-profiling` plugin is Scala 2 only. Retire pending a Scala 3 alternative. | +| `-Xsource:3` scalac flag | Obsolete — the codebase IS Scala 3 now. | +| `-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. | +| `com.avsystem.commons.misc.Implicits` object | Scala 2 macro helpers `infer` / `inferNonMacro` — covered by `scala.compiletime.summon[T]`. Object deleted outright. | +| `com.avsystem.commons.misc.ImplicitNotFound` sealed trait | Scala 2 diagnostic hack: the `@implicitNotFound` message was itself resolved via implicit search, allowing composed error messages (`#{forNotLazy}` / `#{forPlain}` interpolation). No Scala 3 equivalent — `@implicitNotFound` is supported natively but message composition via implicit search is not. Trait deleted outright; dependent diagnostic-only defs removed (`MetadataCompanion.Lazy.notFound`, `BoundedMetadataCompanion.Lazy.notFound`, `AsRaw.notFoundForTry`, `AsReal.notFoundForTry`). Functionality unaffected — these only customized compiler error messages. `ImplicitNotFoundTest` deleted. | ## 2. Deprecated on Scala 3 @@ -101,7 +103,7 @@ with no surviving partners. Six broken-test categories: `MongoIndexTest`, `MongoOrderTest`, `MongoProjectionTest`, `MongoRefTest`, `MongoUpdateTest`, `TypedMongoCollectionTest`, `testEntities`. - **Hocon derivation** — `hocon/.../*.scala` (2 files): `HoconInputTest`, `HoconGenCodecRoundtripTest`. -- **Misc derivation** — `ImplicitNotFoundTest`, `MacroInstancesTest`, `CompilationErrorAssertions`. +- **Misc derivation** — `MacroInstancesTest`, `CompilationErrorAssertions`. Full per-file list with locations is in the Backlog table below (filter rows where Location contains `/src/test/`). @@ -223,7 +225,6 @@ Full per-file list with locations is in the Backlog table below (filter rows whe | `core/src/test/scala/com/avsystem/commons/macros/KnownSubtypesTest.scala:4` | KnownSubtypesTest — depends on TestMacros / scala-2 `def ... = macro ...` | L | | `core/src/test/scala/com/avsystem/commons/macros/TreeForTypeTest.scala:4` | TreeForTypeTest — depends on TestMacros / scala-2 `def ... = macro ...` | L | | `core/src/test/scala/com/avsystem/commons/macros/TypeStringTest.scala:4` | TypeStringTest — depends on TestMacros / scala-2 `def ... = macro ...` | L | -| `core/src/test/scala/com/avsystem/commons/misc/ImplicitNotFoundTest.scala:4` | ImplicitNotFoundTest — depends on stubbed materialize/derivation APIs | M | | `core/src/test/scala/com/avsystem/commons/misc/MacroInstancesTest.scala:4` | MacroInstancesTest — depends on stubbed materialize/derivation APIs | M | | `core/src/test/scala/com/avsystem/commons/serialization/CodecTestData.scala:4` | CodecTestData — depends on stubbed materialize/derivation APIs | M | | `core/src/test/scala/com/avsystem/commons/serialization/GenCodecRoundtripTest.scala:4` | GenCodecRoundtripTest — depends on stubbed materialize/derivation APIs | M | diff --git a/core/src/main/scala/com/avsystem/commons/meta/MetadataCompanion.scala b/core/src/main/scala/com/avsystem/commons/meta/MetadataCompanion.scala index 9c59d6268..65ac7a20c 100644 --- a/core/src/main/scala/com/avsystem/commons/meta/MetadataCompanion.scala +++ b/core/src/main/scala/com/avsystem/commons/meta/MetadataCompanion.scala @@ -1,10 +1,6 @@ package com.avsystem.commons package meta -import com.avsystem.commons.misc.ImplicitNotFound - -import scala.annotation.implicitNotFound - /** Base trait for companion objects of _metadata classes_. A metadata class is a generic class that captures metadata * for some Scala type, typically an RPC interface ([[com.avsystem.commons.rpc.RpcMetadataCompanion * RpcMetadataCompanion]]) or a data type ([[AdtMetadataCompanion]]). @@ -26,10 +22,6 @@ trait MetadataCompanion[M[_]] { // macro effectively turns `metadata` param into by-name param (implicit params by themselves cannot be by-name) // TODO[scala3-port]: lazyMetadata (Scala 2 macro def) (L) implicit def lazyMetadata[Real](implicit metadata: M[Real]): Lazy[Real] = ??? - - @implicitNotFound("#{forNotLazy}") - implicit def notFound[T](implicit forNotLazy: ImplicitNotFound[M[T]]): ImplicitNotFound[Lazy[T]] = - ImplicitNotFound() } } @@ -57,9 +49,5 @@ trait BoundedMetadataCompanion[Hi, Lo <: Hi, M[_ >: Lo <: Hi]] { // macro effectively turns `metadata` param into by-name param (implicit params by themselves cannot be by-name) // TODO[scala3-port]: lazyMetadata (bounded) (Scala 2 macro def) (L) implicit def lazyMetadata[Real >: Lo <: Hi](implicit metadata: M[Real]): Lazy[Real] = ??? - - @implicitNotFound("#{forNotLazy}") - implicit def notFound[T >: Lo <: Hi](implicit forNotLazy: ImplicitNotFound[M[T]]): ImplicitNotFound[Lazy[T]] = - ImplicitNotFound() } } diff --git a/core/src/main/scala/com/avsystem/commons/misc/Implicits.scala b/core/src/main/scala/com/avsystem/commons/misc/Implicits.scala deleted file mode 100644 index 70056cbb8..000000000 --- a/core/src/main/scala/com/avsystem/commons/misc/Implicits.scala +++ /dev/null @@ -1,45 +0,0 @@ -package com.avsystem.commons -package misc - -object Implicits { - // TODO[scala3-port]: infer (Scala 2 macro def) (L) - def infer[T]: T = ??? - // TODO[scala3-port]: infer(clue) (Scala 2 macro def) (L) - def infer[T](clue: String): T = ??? - // TODO[scala3-port]: inferNonMacro (Scala 2 macro def) (L) - def inferNonMacro[T](clue: String): T = ??? -} - -/** Extends the functionality of [[scala.annotation.implicitNotFound]] so that implicit-not-found error message is - * itself resolved using implicit search. This mechanism is used by [[Implicits.infer[T]:T*]] and macro engines that - * use it. - * - * Example: we have a wrapper class `Box[T]` and we want a custom error message when `GenCodec[Box[T]]` for some type - * `T` is not found: - * - * {{{ - * trait Box[T] - * object Box { - * implicit def boxCodec[T: GenCodec]: GenCodec[Box[T]] = ... - * - * @implicitNotFound("GenCodec for Box[$${T}] not found. This is most likely caused by lack of GenCodec[$${T}]") - * implicit def boxCodecNotFound[T]: ImplicitNotFound[GenCodec[Box[T]]] = ImplicitNotFound() - * } - * }}} - * - * It is also possible to compose error message for one type from error messages for other types. The example above - * could reuse the implicit-not-found message for `GenCodec[T]` when building the message for `GenCodec[Box[T]]`: - * - * {{{ - * @implicitNotFound("GenCodec for Box[$${T}] not found, because:\n#{forUnboxed}") - * implicit def boxCodecNotFound[T]( - * implicit forUnboxed: ImplicitNotFound[GenCodec[T]] - * ): ImplicitNotFound[GenCodec[Box[T]]] = ImplicitNotFound() - * }}} - */ -sealed trait ImplicitNotFound[T] -object ImplicitNotFound { - def apply[T](): ImplicitNotFound[T] = throw new NotImplementedError("ImplicitNotFound.apply") - - implicit def dummy[T]: ImplicitNotFound[T] = apply() -} diff --git a/core/src/main/scala/com/avsystem/commons/rpc/AsRawReal.scala b/core/src/main/scala/com/avsystem/commons/rpc/AsRawReal.scala index 760123571..e8f4dbaab 100644 --- a/core/src/main/scala/com/avsystem/commons/rpc/AsRawReal.scala +++ b/core/src/main/scala/com/avsystem/commons/rpc/AsRawReal.scala @@ -2,7 +2,6 @@ package com.avsystem.commons package rpc import com.avsystem.commons.meta.Fallback -import com.avsystem.commons.misc.ImplicitNotFound import com.avsystem.commons.serialization.TransparentWrapping import scala.annotation.implicitNotFound @@ -32,11 +31,6 @@ object AsRaw extends FallbackAsRaw { implicit def identity[A]: AsRaw[A, A] = AsRawReal.identity[A] implicit def forTry[Raw, Real](implicit asRaw: AsRaw[Raw, Real]): AsRaw[Try[Raw], Try[Real]] = _.map(asRaw.asRaw) - - @implicitNotFound("#{forPlain}") - implicit def notFoundForTry[Raw, Real]( - implicit forPlain: ImplicitNotFound[AsRaw[Raw, Real]] - ): ImplicitNotFound[AsRaw[Try[Raw], Try[Real]]] = ImplicitNotFound() } trait FallbackAsRaw { this: AsRaw.type => implicit def fromFallback[Raw, Real](implicit fallback: Fallback[AsRaw[Raw, Real]]): AsRaw[Raw, Real] = @@ -65,11 +59,6 @@ object AsReal extends FallbackAsReal { implicit def identity[A]: AsReal[A, A] = AsRawReal.identity[A] implicit def forTry[Raw, Real](implicit asReal: AsReal[Raw, Real]): AsReal[Try[Raw], Try[Real]] = _.map(asReal.asReal) - - @implicitNotFound("#{forPlain}") - implicit def notFoundForTry[Raw, Real]( - implicit forPlain: ImplicitNotFound[AsReal[Raw, Real]] - ): ImplicitNotFound[AsReal[Try[Raw], Try[Real]]] = ImplicitNotFound() } trait FallbackAsReal { this: AsReal.type => implicit def fromFallback[Raw, Real](implicit fallback: Fallback[AsReal[Raw, Real]]): AsReal[Raw, Real] = diff --git a/core/src/test/scala/com/avsystem/commons/misc/ImplicitNotFoundTest.scala b/core/src/test/scala/com/avsystem/commons/misc/ImplicitNotFoundTest.scala deleted file mode 100644 index 15282cd93..000000000 --- a/core/src/test/scala/com/avsystem/commons/misc/ImplicitNotFoundTest.scala +++ /dev/null @@ -1,32 +0,0 @@ -package com.avsystem.commons -package misc - -// TODO[scala3-port]: ImplicitNotFoundTest — depends on stubbed materialize/derivation APIs (M) -/* -import com.avsystem.commons.testutil.CompilationErrorAssertions -import org.scalatest.funsuite.AnyFunSuite - -import scala.annotation.implicitNotFound - -sealed trait Stuff -object Stuff { - @implicitNotFound("no stuff available") - implicit def inf: ImplicitNotFound[Stuff] = ImplicitNotFound() -} - -sealed trait OtherStuff -object OtherStuff { - @implicitNotFound("no other stuff available because: #{forStuff}") - implicit def inf(implicit forStuff: ImplicitNotFound[Stuff]): ImplicitNotFound[OtherStuff] = ImplicitNotFound() -} - -class ImplicitNotFoundTest extends AnyFunSuite with CompilationErrorAssertions { - test("simple") { - assert(typeErrorFor("Implicits.infer[Stuff]") == "no stuff available") - } - - test("with dependencies") { - assert(typeErrorFor("Implicits.infer[OtherStuff]") == "no other stuff available because: no stuff available") - } -} - */