Skip to content

Merge ValueOf deprecation and shared utils removal to master#836

Merged
halotukozak merged 9 commits intomasterfrom
add-mima-test
Apr 22, 2026
Merged

Merge ValueOf deprecation and shared utils removal to master#836
halotukozak merged 9 commits intomasterfrom
add-mima-test

Conversation

@halotukozak
Copy link
Copy Markdown
Member

@halotukozak halotukozak commented Apr 22, 2026

GitHub didn't changes the target branch for some reason and #832 #829 was merged to the add-mima-test

halotukozak and others added 9 commits April 16, 2026 18:04
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`
@halotukozak halotukozak self-assigned this Apr 22, 2026
Copilot AI review requested due to automatic review settings April 22, 2026 07:11
@halotukozak halotukozak changed the title Merge deprecations to master Merge ValueOf deprecation and shared utils removal to master Apr 22, 2026
@halotukozak halotukozak merged commit ccb821f into master Apr 22, 2026
13 checks passed
@halotukozak halotukozak deleted the add-mima-test branch April 22, 2026 07:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ValueOf in favor of scala.ValueOf and update call sites accordingly.
  • Remove deprecated SharedExtensions iterator/orderings helpers and add MiMa filters for the removals.
  • Add binary-compatibility constructors for Has*WithDeps helpers 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")
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
@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")

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +42
@bincompat
@nowarn("msg=deprecated")
private[serialization] def this(applyUnapplyProvider: ValueOf[D], instances: MacroInstances[D, () => GenCodec[T]]) =
this()(instances, applyUnapplyProvider.toScala)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +34
private[serialization] def this(
applyUnapplyProvider: ValueOf[D],
instances: MacroInstances[(CborOptimizedCodecs, D), CborAdtInstances[T]],
) = this()(using instances, applyUnapplyProvider.toScala)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants