Merge ValueOf deprecation and shared utils removal to master#836
Merge ValueOf deprecation and shared utils removal to master#836halotukozak merged 9 commits intomasterfrom
Conversation
Scala 2.13 provides `scala.ValueOf[T]` natively with compiler
auto-materialization for singleton types, making the custom
macro-materialized typeclass redundant. Internal call sites in the
serialization layer migrated to `scala.ValueOf`; `ValueOfTest` keeps
the deprecated API under test via `@nowarn("cat=deprecation")` until
removal.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
remove OrderingOps and some IteratorOps
deprecate `ValueOf` in favor of standard library `scala.ValueOf`
There was a problem hiding this comment.
Pull request overview
This PR consolidates recent deprecations by migrating away from custom helper APIs (notably com.avsystem.commons.misc.ValueOf and some SharedExtensions ops) in favor of Scala 2.13 standard library equivalents, while updating build MiMa configuration and adjusting impacted code/tests.
Changes:
- Deprecate
com.avsystem.commons.misc.ValueOfin favor ofscala.ValueOfand update call sites accordingly. - Remove deprecated
SharedExtensionsiterator/orderings helpers and add MiMa filters for the removals. - Add binary-compatibility constructors for
Has*WithDepshelpers and suppress new deprecation warnings in tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| project/Commons.scala | Adds core MiMa filters and applies them to core JVM/JS subprojects. |
| mongo/jvm/src/main/scala/com/avsystem/commons/mongo/typed/MongoFormat.scala | Switches imports and replaces custom ValueOf usage with scala.ValueOf. |
| macros/src/main/scala/com/avsystem/commons/macros/misc/MiscMacros.scala | Removes macro materializer previously used by custom ValueOf. |
| core/src/test/scala/com/avsystem/commons/misc/ValueOfTest.scala | Suppresses deprecation warnings introduced by deprecating ValueOf. |
| core/src/test/scala/com/avsystem/commons/misc/AdtMetadataTest.scala | Replaces custom ValueOf metadata dependency with scala.ValueOf. |
| core/src/main/scala/com/avsystem/commons/serialization/cbor/CborAdtMetadata.scala | Migrates HasCborCodecWithDeps to scala.ValueOf and adds a compatibility constructor. |
| core/src/main/scala/com/avsystem/commons/serialization/HasGenCodec.scala | Migrates Has*WithDeps helpers to scala.ValueOf and adds compatibility constructors. |
| core/src/main/scala/com/avsystem/commons/misc/ValueOf.scala | Deprecates custom ValueOf and introduces conversion to/from scala.ValueOf. |
| core/src/main/scala/com/avsystem/commons/SharedExtensions.scala | Removes deprecated iterator/orderings ops and marks remaining ordering helpers deprecated. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def apply[T](implicit vof: ValueOf[T]): T = vof.value | ||
|
|
||
| implicit def mkValueOf[T]: ValueOf[T] = macro MiscMacros.mkValueOf[T] | ||
| @deprecated("Use scala.ValueOf[T] from the standard library (available since Scala 2.13)", "2.28.0") |
There was a problem hiding this comment.
ValueOf used to expose an implicit macro mkValueOf[T], and removing it is binary-incompatible: already-compiled client code that relied on that implicit will have a hard reference to com.avsystem.commons.misc.ValueOf$.mkValueOf and can fail with NoSuchMethodError at runtime. To preserve binary compatibility, keep a (deprecated) mkValueOf method with the old name/signature that delegates to the new scala.ValueOf-based implementation.
| @deprecated("Use scala.ValueOf[T] from the standard library (available since Scala 2.13)", "2.28.0") | |
| @deprecated("Use scala.ValueOf[T] from the standard library (available since Scala 2.13)", "2.28.0") | |
| implicit def mkValueOf[T](implicit vof: scala.ValueOf[T]): ValueOf[T] = fromScala(vof) | |
| @deprecated("Use scala.ValueOf[T] from the standard library (available since Scala 2.13)", "2.28.0") |
| @bincompat | ||
| @nowarn("msg=deprecated") | ||
| private[serialization] def this(applyUnapplyProvider: ValueOf[D], instances: MacroInstances[D, () => GenCodec[T]]) = | ||
| this()(instances, applyUnapplyProvider.toScala) |
There was a problem hiding this comment.
The added "bincompat" secondary constructor is declared private[serialization], but the original constructor (with ValueOf[D] and MacroInstances[...]) was public. Already-compiled user code that extends these Has*WithDeps base classes will invoke the old super-constructor and may fail with IllegalAccessError if the replacement constructor is not public. Make the compatibility constructor public (and deprecated/nowarn if needed) so external subclasses can still link/run.
| private[serialization] def this( | ||
| applyUnapplyProvider: ValueOf[D], | ||
| instances: MacroInstances[(CborOptimizedCodecs, D), CborAdtInstances[T]], | ||
| ) = this()(using instances, applyUnapplyProvider.toScala) |
There was a problem hiding this comment.
this()(using instances, ...) uses Scala 3 "using"-argument syntax, which is not valid Scala 2.13 syntax (even with -Xsource:3) and should not compile. Also, similar to other Has*WithDeps changes, the compatibility constructor is private[serialization] even though the original constructor was public, which can break binary compatibility for external subclasses. Replace the call with Scala 2 syntax and make the compatibility constructor public.
| private[serialization] def this( | |
| applyUnapplyProvider: ValueOf[D], | |
| instances: MacroInstances[(CborOptimizedCodecs, D), CborAdtInstances[T]], | |
| ) = this()(using instances, applyUnapplyProvider.toScala) | |
| def this( | |
| applyUnapplyProvider: ValueOf[D], | |
| instances: MacroInstances[(CborOptimizedCodecs, D), CborAdtInstances[T]], | |
| ) = this()(instances, applyUnapplyProvider.toScala) |
GitHub didn't changes the target branch for some reason and #832 #829 was merged to the
add-mima-test