Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ the bottom of this file. Restoration ships incrementally per feature area.
compiles).
- `enum` was renamed to `e` at one call site in `GenKeyCodec` (`enum` is reserved in Scala 3).
- `@targetName` annotation added to `CloseableIterator` overloaded methods.
- HKT wildcard `_` → `?` in applied positions (slice 3.2). Type-argument-position syntax only;
kind-parameter declarations (`class Foo[F[_]]`, `def baz[M[_], A]`, etc.) preserved per Scala 3.
Pure type-level rename — no source-compat impact for downstream callers; type-argument site syntax
only.

### mongo

Expand All @@ -63,6 +67,8 @@ the bottom of this file. Restoration ships incrementally per feature area.
Scala 3 forbids type projections on non-concrete prefixes). Public-API signature change.
- `BsonValueOutput.write` / `BsonValueInput.read` call sites require explicit `using` keyword.
- `MongoPolyDataCompanion` / `TypedMapFormat` / `TypedMapRefOps` widened from `K[_]` / `D[_]` to `K[Any]` / `D[Any]`.
- HKT wildcard `_` → `?` in applied positions (slice 3.2). Same as core entry — pure
type-argument-position syntax change with no source-compat impact.

### hocon

Expand Down
26 changes: 13 additions & 13 deletions core/src/main/scala/com/avsystem/commons/di/Component.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import java.util.concurrent.atomic.AtomicReference
import scala.annotation.compileTimeOnly
import scala.annotation.unchecked.uncheckedVariance

case class ComponentInitializationException(component: Component[_], cause: Throwable)
case class ComponentInitializationException(component: Component[?], cause: Throwable)
extends Exception(s"failed to initialize component ${component.info}", cause)

case class DependencyCycleException(cyclePath: List[Component[_]])
case class DependencyCycleException(cyclePath: List[Component[?]])
extends Exception(
s"component dependency cycle detected:\n${cyclePath.iterator.map(_.info).map(" " + _).mkString(" ->\n")}"
)
Expand Down Expand Up @@ -46,7 +46,7 @@ object ComponentInfo {
*/
final class Component[+T](
val info: ComponentInfo,
deps: => IndexedSeq[Component[_]],
deps: => IndexedSeq[Component[?]],
creator: IndexedSeq[Any] => ExecutionContext => Future[T],
destroyer: DestroyFunction[T] = Component.emptyDestroy,
cachedStorage: Opt[AtomicReference[Future[T]]] = Opt.Empty,
Expand All @@ -61,18 +61,18 @@ final class Component[+T](
/** Returns dependencies of this component extracted from the component definition. You can use this to inspect the
* dependency graph without initializing any components.
*/
lazy val dependencies: IndexedSeq[Component[_]] = deps
lazy val dependencies: IndexedSeq[Component[?]] = deps

private[this] val storage: AtomicReference[Future[T]] =
cachedStorage.getOrElse(new AtomicReference)

private def sameStorage(otherStorage: AtomicReference[_]): Boolean =
private def sameStorage(otherStorage: AtomicReference[?]): Boolean =
storage eq otherStorage

// equality based on storage identity is important for cycle detection with cached components
override def hashCode(): Int = storage.hashCode()
override def equals(obj: Any): Boolean = obj match {
case c: Component[_] => c.sameStorage(storage)
case c: Component[?] => c.sameStorage(storage)
case _ => false
}

Expand Down Expand Up @@ -106,7 +106,7 @@ final class Component[+T](

/** Forces a dependency on another component or components.
*/
def dependsOn(moreDeps: Component[_]*): Component[T] =
def dependsOn(moreDeps: Component[?]*): Component[T] =
new Component(info, deps ++ moreDeps, creator, destroyer, cachedStorage)

/** Specifies an asynchronous function that will be used to destroy this component, i.e. free up any resources that
Expand Down Expand Up @@ -189,7 +189,7 @@ object Component {
def async[T](definition: => T): ExecutionContext => Future[T] =
implicit ctx => Future(definition)

def validateAll(components: Seq[Component[_]]): Unit =
def validateAll(components: Seq[Component[?]]): Unit =
GraphUtils.dfs(components)(
_.dependencies.toList,
onCycle = (node, stack) => {
Expand All @@ -203,9 +203,9 @@ object Component {
* ensured that a component is only destroyed after all components that depend on it are destroyed (reverse
* initialization order). Independent components are destroyed in parallel, using given `ExecutionContext`.
*/
def destroyAll(components: Seq[Component[_]])(implicit ec: ExecutionContext): Future[Unit] = {
val reverseGraph = new MHashMap[Component[_], MListBuffer[Component[_]]]
val terminals = new MHashSet[Component[_]]
def destroyAll(components: Seq[Component[?]])(implicit ec: ExecutionContext): Future[Unit] = {
val reverseGraph = new MHashMap[Component[?], MListBuffer[Component[?]]]
val terminals = new MHashSet[Component[?]]
GraphUtils.dfs(components)(
_.dependencies.toList,
onEnter = { (c, _) =>
Expand All @@ -218,9 +218,9 @@ object Component {
terminals += c
},
)
val destroyFutures = new MHashMap[Component[_], Future[Unit]]
val destroyFutures = new MHashMap[Component[?], Future[Unit]]

def doDestroy(c: Component[_]): Future[Unit] =
def doDestroy(c: Component[?]): Future[Unit] =
destroyFutures.getOrElseUpdate(c, Future.traverse(reverseGraph(c))(doDestroy).flatMap(_ => c.doDestroy))

Future.traverse(reverseGraph.keys)(doDestroy).toUnit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait Components extends ComponentsLowPrio {
protected def asyncSingleton[T](definition: ExecutionContext => Future[T])(implicit sourceInfo: SourceInfo)
: Component[T] = ???

private lazy val singletonsCache = new ConcurrentHashMap[ComponentInfo, AtomicReference[Future[_]]]
private lazy val singletonsCache = new ConcurrentHashMap[ComponentInfo, AtomicReference[Future[?]]]

protected def cached[T](component: Component[T], freshInfo: ComponentInfo): Component[T] = {
val cacheStorage =
Expand Down
16 changes: 8 additions & 8 deletions core/src/main/scala/com/avsystem/commons/misc/TypeString.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ object TypeString {
// TODO[scala3-port]: TypeString.materialize (Scala 2 macro def) (L)
implicit def materialize[T]: TypeString[T] = ???

implicit val keyCodec: GenKeyCodec[TypeString[_]] =
GenKeyCodec.create[TypeString[_]](new TypeString(_), _.value)
implicit val keyCodec: GenKeyCodec[TypeString[?]] =
GenKeyCodec.create[TypeString[?]](new TypeString(_), _.value)

implicit val codec: GenCodec[TypeString[_]] =
GenCodec.nonNullSimple[TypeString[_]](i => new TypeString(i.readString()), (o, ts) => o.writeString(ts.value))
implicit val codec: GenCodec[TypeString[?]] =
GenCodec.nonNullSimple[TypeString[?]](i => new TypeString(i.readString()), (o, ts) => o.writeString(ts.value))
}

/** Typeclass that contains JVM fully qualified class name corresponding to given type. `JavaClassName.of[T]` is always
Expand Down Expand Up @@ -80,11 +80,11 @@ object JavaClassName extends JavaClassNameLowPrio {
new JavaClassName("[" + elementName)
}

implicit val keyCodec: GenKeyCodec[JavaClassName[_]] =
GenKeyCodec.create[JavaClassName[_]](new JavaClassName(_), _.value)
implicit val keyCodec: GenKeyCodec[JavaClassName[?]] =
GenKeyCodec.create[JavaClassName[?]](new JavaClassName(_), _.value)

implicit val codec: GenCodec[JavaClassName[_]] =
GenCodec.nonNullSimple[JavaClassName[_]](i => new JavaClassName(i.readString()), (o, ts) => o.writeString(ts.value))
implicit val codec: GenCodec[JavaClassName[?]] =
GenCodec.nonNullSimple[JavaClassName[?]](i => new JavaClassName(i.readString()), (o, ts) => o.writeString(ts.value))
}
trait JavaClassNameLowPrio { this: JavaClassName.type =>
// TODO[scala3-port]: JavaClassName.materialize (Scala 2 macro def) (L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object TypedMap {
def empty[K[_]]: TypedMap[K] =
new TypedMap[K](Map.empty)

def apply[K[_]](entries: Entry[K, _]*): TypedMap[K] = {
def apply[K[_]](entries: Entry[K, ?]*): TypedMap[K] = {
val raw = Map.newBuilder[K[Any], Any]
entries.foreach(e => raw += e.pair.asInstanceOf[(K[Any], Any)])
new TypedMap[K](raw.result())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ object RpcMetadata {
// TODO[scala3-port]: RpcMetadata.auto (Scala 2 macro def) (L)
def auto[T]: T = ???

def nextInstance[T](it: Iterator[_], description: String): T =
def nextInstance[T](it: Iterator[?], description: String): T =
if (it.hasNext) it.next().asInstanceOf[T]
else throw new NoSuchElementException(s"typeclass instance for $description was not provided")
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ trait RPCFramework {
trait Signature {
@reifyName def name: String
@multi
@rpcParamMetadata def paramMetadata: List[ParamMetadata[_]]
@rpcParamMetadata def paramMetadata: List[ParamMetadata[?]]
@reifyAnnot
@multi def annotations: List[MetadataAnnotation]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait ProcedureRPCFramework extends RPCFramework {

case class ProcedureSignature(
name: String,
paramMetadata: List[ParamMetadata[_]],
paramMetadata: List[ParamMetadata[?]],
annotations: List[MetadataAnnotation],
) extends Signature
with TypedMetadata[Unit]
Expand All @@ -34,7 +34,7 @@ trait FunctionRPCFramework extends RPCFramework {

case class FunctionSignature[T](
name: String,
paramMetadata: List[ParamMetadata[_]],
paramMetadata: List[ParamMetadata[?]],
annotations: List[MetadataAnnotation],
@infer resultTypeMetadata: ResultTypeMetadata[T],
) extends Signature
Expand All @@ -58,7 +58,7 @@ trait GetterRPCFramework extends RPCFramework {

case class GetterSignature[T](
name: String,
paramMetadata: List[ParamMetadata[_]],
paramMetadata: List[ParamMetadata[?]],
annotations: List[MetadataAnnotation],
@infer @checked resultMetadata: RPCMetadata.Lazy[T],
) extends Signature
Expand All @@ -75,8 +75,8 @@ trait StandardRPCFramework extends GetterRPCFramework with FunctionRPCFramework
@reifyName name: String,
@reifyAnnot @multi annotations: List[MetadataAnnotation],
@multi @verbatim @rpcMethodMetadata procedureSignatures: Map[String, ProcedureSignature],
@multi @rpcMethodMetadata functionSignatures: Map[String, FunctionSignature[_]],
@multi @rpcMethodMetadata getterSignatures: Map[String, GetterSignature[_]],
@multi @rpcMethodMetadata functionSignatures: Map[String, FunctionSignature[?]],
@multi @rpcMethodMetadata getterSignatures: Map[String, GetterSignature[?]],
)
object RPCMetadata extends RpcMetadataCompanion[RPCMetadata]
}
Expand All @@ -91,7 +91,7 @@ trait OneWayRPCFramework extends GetterRPCFramework with ProcedureRPCFramework {
@reifyName name: String,
@reifyAnnot @multi annotations: List[MetadataAnnotation],
@multi @verbatim @rpcMethodMetadata procedureSignatures: Map[String, ProcedureSignature],
@multi @rpcMethodMetadata getterSignatures: Map[String, GetterSignature[_]],
@multi @rpcMethodMetadata getterSignatures: Map[String, GetterSignature[?]],
)
object RPCMetadata extends RpcMetadataCompanion[RPCMetadata]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object FieldValues {
}
final class FieldValues(
private val fieldNames: Array[String],
codecs: Array[GenCodec[_]],
codecs: Array[GenCodec[?]],
ofWhat: OptArg[String] = OptArg.Empty,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ object GenCodec extends RecursiveAutoCodecs with TupleGenCodecs {
}
}

def underlyingCodec(codec: GenCodec[_]): GenCodec[_] = codec match {
case tc: Transformed[_, _] => underlyingCodec(tc.wrapped)
def underlyingCodec(codec: GenCodec[?]): GenCodec[?] = codec match {
case tc: Transformed[?, ?] => underlyingCodec(tc.wrapped)
case _ => codec
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ trait Output extends Any with AcceptsCustomEvents {
* [[com.avsystem.commons.serialization.InputMetadata InputMetadata]] identifier. If this method returns `false` then
* this `Output` does not support this medatata type and codec should fall back to some other serialization strategy.
*/
def keepsMetadata(metadata: InputMetadata[_]): Boolean = false
def keepsMetadata(metadata: InputMetadata[?]): Boolean = false

/** This ugly workaround has been introduced when standard `Option` encoding changed from zero-or-one element list
* encoding to unwrapped-or-null encoding which effectively disallowed serializing `null` and `Some(null)`. If some
Expand Down Expand Up @@ -168,7 +168,7 @@ trait SequentialOutput extends Any with AcceptsCustomEvents {
/** Based on given collection's `knownSize` and [[sizePolicy]], declares the size of this output as size of this
* collection if it is either cheap or required to do so.
*/
final def declareSizeOf(coll: BIterable[_]): Unit = sizePolicy match {
final def declareSizeOf(coll: BIterable[?]): Unit = sizePolicy match {
case SizePolicy.Ignored =>
case SizePolicy.Optional =>
coll.knownSize match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object CborAdtMetadata extends AdtMetadataCompanion[CborAdtMetadata] {
final class CborKeyInfo[T](
@reifyName val sourceName: String,
@optional @reifyAnnot val nameAnnot: Opt[name],
@optional @reifyAnnot val cborKey: Opt[cborKey[_]],
@optional @reifyAnnot val cborKey: Opt[cborKey[?]],
) {
val stringKey: String = nameAnnot.fold(sourceName)(_.name)
val rawKey: RawCbor = cborKey.fold(CborOutput.writeRawCbor(stringKey))(_.rawKey)
Expand All @@ -86,9 +86,9 @@ object CborAdtMetadata extends AdtMetadataCompanion[CborAdtMetadata] {
@positioned(positioned.here)
final class Union[T](
@reifyName val sourceName: String,
@optional @reifyAnnot val discriminator: Opt[cborDiscriminator[_]],
@optional @reifyAnnot val discriminator: Opt[cborDiscriminator[?]],
@optional @reifyAnnot val flattenAnnot: Opt[flatten],
@multi @adtCaseMetadata val cases: List[Case[_]],
@multi @adtCaseMetadata val cases: List[Case[?]],
) extends CborAdtMetadata[T] { union =>
private val caseNamesKeyCodec =
new MappingCborKeyCodec(cases.map(_.keyInfo))
Expand All @@ -106,7 +106,7 @@ object CborAdtMetadata extends AdtMetadataCompanion[CborAdtMetadata] {
nestedCodec.caseNames,
nestedCodec.cases,
) {
def caseDependencies: Array[GenCodec[_]] =
def caseDependencies: Array[GenCodec[?]] =
(nestedCodec.caseDependencies.iterator zip union.cases.iterator).map {
case (caseCodec: ApplyUnapplyCodec[Any @unchecked], theCase: CborAdtMetadata.Record[Any @unchecked]) =>
theCase.adjustCodec(caseCodec)
Expand Down Expand Up @@ -137,9 +137,9 @@ object CborAdtMetadata extends AdtMetadataCompanion[CborAdtMetadata] {
override protected def doReadCaseName(input: Input): String =
input.readCustom(RawCbor).map(caseNamesKeyCodec.strKeys).getOrElse(super.doReadCaseName(input))

def oooDependencies: Array[GenCodec[_]] = flatCodec.oooDependencies
def oooDependencies: Array[GenCodec[?]] = flatCodec.oooDependencies

def caseDependencies: Array[GenCodec.OOOFieldsObjectCodec[_]] =
def caseDependencies: Array[GenCodec.OOOFieldsObjectCodec[?]] =
(flatCodec.caseDependencies.iterator zip union.cases.iterator).map {
case (caseCodec: ApplyUnapplyCodec[Any @unchecked], theCase: CborAdtMetadata.Record[Any @unchecked]) =>
theCase.adjustFlatCaseCodec(caseCodec)
Expand Down Expand Up @@ -175,7 +175,7 @@ object CborAdtMetadata extends AdtMetadataCompanion[CborAdtMetadata] {
@positioned(positioned.here)
final class Record[T](
@composite val keyInfo: CborKeyInfo[T],
@multi @adtParamMetadata val fields: List[Field[_]],
@multi @adtParamMetadata val fields: List[Field[?]],
) extends Case[T] {
private val keyCodec = new MappingCborKeyCodec(fields.map(_.keyInfo))

Expand Down Expand Up @@ -223,7 +223,7 @@ object CborAdtMetadata extends AdtMetadataCompanion[CborAdtMetadata] {
def validate(): Unit = ()
}

private class MappingCborKeyCodec(keyInfos: List[CborKeyInfo[_]]) extends CborKeyCodec {
private class MappingCborKeyCodec(keyInfos: List[CborKeyInfo[?]]) extends CborKeyCodec {
val rawKeys: Map[String, RawCbor] =
keyInfos.mkMap(_.stringKey, _.rawKey)
val strKeys: Map[RawCbor, String] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class CborOutput(out: DataOutput, keyCodec: CborKeyCodec, sizePolicy: SizePolicy
super.writeCustom(typeMarker, value)
}

override def keepsMetadata(metadata: InputMetadata[_]): Boolean = metadata match {
override def keepsMetadata(metadata: InputMetadata[?]): Boolean = metadata match {
case InitialByte | Tags => true
case _ => super.keepsMetadata(metadata)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ final class JsonStringOutput(builder: JStringBuilder, options: JsonOptions = Jso

def writeRawJson(json: String): Unit = builder.append(json)

override def keepsMetadata(metadata: InputMetadata[_]): Boolean =
override def keepsMetadata(metadata: InputMetadata[?]): Boolean =
metadata == JsonType

override def writeCustom[T](typeMarker: TypeMarker[T], value: T): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class ApplyUnapplyCodec[T](
) extends ErrorReportingCodec[T]
with OOOFieldsObjectCodec[T] {

protected def dependencies: Array[GenCodec[_]]
protected def dependencies: Array[GenCodec[?]]
protected def instantiate(fieldValues: FieldValues): T

private[this] lazy val deps = dependencies
Expand Down Expand Up @@ -130,7 +130,7 @@ abstract class SealedHierarchyCodec[T](
val typeRepr: String,
val nullable: Boolean,
val caseNames: Array[String],
val cases: Array[Class[_]],
val cases: Array[Class[?]],
) extends ErrorReportingCodec[T]
with ObjectCodec[T] {

Expand All @@ -149,10 +149,10 @@ abstract class NestedSealedHierarchyCodec[T](
typeRepr: String,
nullable: Boolean,
caseNames: Array[String],
cases: Array[Class[_]],
cases: Array[Class[?]],
) extends SealedHierarchyCodec[T](typeRepr, nullable, caseNames, cases) {

def caseDependencies: Array[GenCodec[_]]
def caseDependencies: Array[GenCodec[?]]

private[this] lazy val caseDeps = caseDependencies

Expand All @@ -177,16 +177,16 @@ abstract class FlatSealedHierarchyCodec[T](
typeRepr: String,
nullable: Boolean,
caseNames: Array[String],
cases: Array[Class[_]],
cases: Array[Class[?]],
val oooFieldNames: Array[String],
val caseDependentFieldNames: Set[String],
override val caseFieldName: String,
val defaultCaseIdx: Int,
val defaultCaseTransient: Boolean,
) extends SealedHierarchyCodec[T](typeRepr, nullable, caseNames, cases) {

def oooDependencies: Array[GenCodec[_]]
def caseDependencies: Array[OOOFieldsObjectCodec[_]]
def oooDependencies: Array[GenCodec[?]]
def caseDependencies: Array[OOOFieldsObjectCodec[?]]

private[this] lazy val oooDeps = oooDependencies
private[this] lazy val caseDeps = caseDependencies
Expand Down Expand Up @@ -386,7 +386,7 @@ abstract class JavaBuilderBasedCodec[T, B](
) extends ErrorReportingCodec[T]
with GenCodec.ObjectCodec[T] {

protected def dependencies: Array[GenCodec[_]]
protected def dependencies: Array[GenCodec[?]]

private lazy val deps = dependencies

Expand Down
Loading
Loading