From 0a6bbf06a308f90064c7ccb3ef03a1d2e3ddce73 Mon Sep 17 00:00:00 2001 From: Mateusz Kubuszok Date: Thu, 4 Apr 2024 23:12:38 +0200 Subject: [PATCH] Rename more type parameters, utilitie and change the order of type paremeters in Path for better readability and consistency --- .../dsl/PartialTransformerDefinition.scala | 46 +++++----- .../chimney/dsl/PartialTransformerInto.scala | 64 +++++++------- .../chimney/dsl/PatcherDefinition.scala | 14 +-- .../scalaland/chimney/dsl/PatcherUsing.scala | 21 ++--- .../chimney/dsl/TransformerDefinition.scala | 41 ++++----- .../dsl/TransformerDefinitionCommons.scala | 2 +- .../chimney/dsl/TransformerInto.scala | 43 +++++----- .../compiletime/ChimneyTypesPlatform.scala | 86 +++++++++---------- .../derivation/patcher/PatcherMacros.scala | 12 +-- .../transformer/TransformerMacros.scala | 26 +++--- .../PartialTransformerDefinitionMacros.scala | 48 +++++------ .../dsl/PartialTransformerIntoMacros.scala | 48 +++++------ .../dsl/TransformerDefinitionMacros.scala | 31 ++++--- .../dsl/TransformerIntoMacros.scala | 26 +++--- .../compiletime/dsl/utils/DslMacroUtils.scala | 38 ++++---- .../dsl/PartialTransformerDefinition.scala | 39 ++++----- .../chimney/dsl/PartialTransformerInto.scala | 71 ++++++++------- .../chimney/dsl/PatcherDefinition.scala | 18 ++-- .../scalaland/chimney/dsl/PatcherUsing.scala | 23 ++--- .../chimney/dsl/TransformerDefinition.scala | 45 +++++----- .../dsl/TransformerDefinitionCommons.scala | 2 +- .../chimney/dsl/TransformerInto.scala | 45 +++++----- .../compiletime/ChimneyTypesPlatform.scala | 74 ++++++++-------- .../derivation/patcher/PatcherMacros.scala | 12 +-- .../transformer/TransformerMacros.scala | 38 ++++---- .../PartialTransformerDefinitionMacros.scala | 68 +++++++-------- .../dsl/PartialTransformerIntoMacros.scala | 73 ++++++++-------- .../dsl/PatcherDefinitionMacros.scala | 4 +- .../dsl/TransformerDefinitionMacros.scala | 40 ++++----- .../dsl/TransformerIntoMacros.scala | 40 ++++----- .../compiletime/dsl/utils/DslMacroUtils.scala | 11 ++- .../internal/compiletime/ChimneyTypes.scala | 4 +- .../derivation/patcher/Configurations.scala | 15 ++-- .../derivation/patcher/Gateway.scala | 8 +- .../transformer/Configurations.scala | 81 +++++++++-------- .../derivation/transformer/Gateway.scala | 16 ++-- .../rules/TransformImplicitRuleModule.scala | 2 +- .../TransformProductToProductRuleModule.scala | 8 +- ...HierarchyToSealedHierarchyRuleModule.scala | 2 +- .../rules/TransformSubtypesRuleModule.scala | 2 +- .../TransformTypeToValueClassRuleModule.scala | 2 +- .../TransformValueClassToTypeRuleModule.scala | 2 +- ...formValueClassToValueClassRuleModule.scala | 2 +- .../chimney/internal/runtime/Path.scala | 4 +- .../runtime/TransformerOverrides.scala | 18 ++-- 45 files changed, 671 insertions(+), 644 deletions(-) diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala index 79b24b381..853206e12 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala @@ -9,20 +9,20 @@ import scala.language.experimental.macros /** Allows customization of [[io.scalaland.chimney.PartialTransformer]] derivation. * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * * @since 0.7.0 */ -final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class PartialTransformerDefinition[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val runtimeData: TransformerDefinitionCommons.RuntimeDataStore ) extends TransformerFlagsDsl[Lambda[ - `Flags1 <: TransformerFlags` => PartialTransformerDefinition[From, To, Cfg, Flags1] + `Flags1 <: TransformerFlags` => PartialTransformerDefinition[From, To, Overrides, Flags1] ], Flags] with TransformerDefinitionCommons[ - Lambda[`Cfg1 <: TransformerOverrides` => PartialTransformerDefinition[From, To, Cfg1, Flags]] + Lambda[`Overrides1 <: TransformerOverrides` => PartialTransformerDefinition[From, To, Overrides1, Flags]] ] with WithRuntimeDataStore { @@ -43,7 +43,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, def withFieldConst[T, U](selector: To => T, value: U)(implicit ev: U <:< T ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withFieldConstImpl[From, To, Cfg, Flags] + macro PartialTransformerDefinitionMacros.withFieldConstImpl[From, To, Overrides, Flags] /** Use provided partial result `value` for field picked using `selector`. * @@ -62,7 +62,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, def withFieldConstPartial[T, U](selector: To => T, value: partial.Result[U])(implicit ev: U <:< T ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withFieldConstPartialImpl[From, To, Cfg, Flags] + macro PartialTransformerDefinitionMacros.withFieldConstPartialImpl[From, To, Overrides, Flags] /** Use function `f` to compute value of field picked using `selector`. * @@ -81,7 +81,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, def withFieldComputed[T, U](selector: To => T, f: From => U)(implicit ev: U <:< T ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withFieldComputedImpl[From, To, Cfg, Flags] + macro PartialTransformerDefinitionMacros.withFieldComputedImpl[From, To, Overrides, Flags] /** Use function `f` to compute partial result for field picked using `selector`. * @@ -101,7 +101,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, selector: To => T, f: From => partial.Result[U] )(implicit ev: U <:< T): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withFieldComputedPartialImpl[From, To, Cfg, Flags] + macro PartialTransformerDefinitionMacros.withFieldComputedPartialImpl[From, To, Overrides, Flags] /** Use `selectorFrom` field in `From` to obtain the value of `selectorTo` field in `To` * @@ -121,7 +121,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, selectorFrom: From => T, selectorTo: To => U ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withFieldRenamedImpl[From, To, Cfg, Flags] + macro PartialTransformerDefinitionMacros.withFieldRenamedImpl[From, To, Overrides, Flags] /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another. * @@ -132,16 +132,16 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerDefinition]] * * @since 0.7.0 */ - def withCoproductInstance[Inst]( - f: Inst => To + def withCoproductInstance[Subtype]( + f: Subtype => To ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withCoproductInstanceImpl[From, To, Cfg, Flags, Inst] + macro PartialTransformerDefinitionMacros.withCoproductInstanceImpl[From, To, Overrides, Flags, Subtype] /** Use `f` to calculate the (missing) coproduct instance partial result when mapping one coproduct into another. * @@ -152,16 +152,16 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerDefinition]] * * @since 0.7.0 */ - def withCoproductInstancePartial[Inst]( - f: Inst => partial.Result[To] + def withCoproductInstancePartial[Subtype]( + f: Subtype => partial.Result[To] ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withCoproductInstancePartialImpl[From, To, Cfg, Flags, Inst] + macro PartialTransformerDefinitionMacros.withCoproductInstancePartialImpl[From, To, Overrides, Flags, Subtype] /** Use `f` instead of the primary constructor to construct the `To` value. * @@ -180,7 +180,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, def withConstructor[Ctor]( f: Ctor )(implicit ev: IsFunction.Of[Ctor, To]): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withConstructorImpl[From, To, Cfg, Flags] + macro PartialTransformerDefinitionMacros.withConstructorImpl[From, To, Overrides, Flags] /** Use `f` instead of the primary constructor to parse into `partial.Result[To]` value. * @@ -201,7 +201,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, )(implicit ev: IsFunction.Of[Ctor, partial.Result[To]] ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerDefinitionMacros.withConstructorPartialImpl[From, To, Cfg, Flags] + macro PartialTransformerDefinitionMacros.withConstructorPartialImpl[From, To, Overrides, Flags] /** Build Partial Transformer using current configuration. * @@ -215,7 +215,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, def buildTransformer[ImplicitScopeFlags <: TransformerFlags](implicit tc: io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags] ): PartialTransformer[From, To] = - macro TransformerMacros.derivePartialTransformerWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags] + macro TransformerMacros.derivePartialTransformerWithConfig[From, To, Overrides, Flags, ImplicitScopeFlags] private[chimney] def addOverride(overrideData: Any): this.type = new PartialTransformerDefinition(overrideData +: runtimeData).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerInto.scala b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerInto.scala index 84ec16d88..25d66aec6 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerInto.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PartialTransformerInto.scala @@ -7,23 +7,23 @@ import io.scalaland.chimney.internal.runtime.{IsFunction, TransformerFlags, Tran import scala.language.experimental.macros -/** Provides DSL for configuring [[io.scalaland.chimney.PartialTransformer]]'s - * generation and using the result to transform value at the same time +/** Provides DSL for configuring [[io.scalaland.chimney.PartialTransformer]]'s generation and using the result + * to transform value at the same time * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * @param source object to transform * @param td transformer definition * * @since 0.7.0 */ -final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class PartialTransformerInto[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val source: From, - val td: PartialTransformerDefinition[From, To, Cfg, Flags] + val td: PartialTransformerDefinition[From, To, Overrides, Flags] ) extends TransformerFlagsDsl[Lambda[ - `Flags1 <: TransformerFlags` => PartialTransformerInto[From, To, Cfg, Flags1] + `Flags1 <: TransformerFlags` => PartialTransformerInto[From, To, Overrides, Flags1] ], Flags] with WithRuntimeDataStore { @@ -44,7 +44,7 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags def withFieldConst[T, U](selector: To => T, value: U)(implicit ev: U <:< T ): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withFieldConstImpl[From, To, Cfg, Flags] + macro PartialTransformerIntoMacros.withFieldConstImpl[From, To, Overrides, Flags] /** Use provided partial result `value` for field picked using `selector`. * @@ -64,7 +64,7 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags selector: To => T, value: partial.Result[U] )(implicit ev: U <:< T): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withFieldConstPartialImpl[From, To, Cfg, Flags] + macro PartialTransformerIntoMacros.withFieldConstPartialImpl[From, To, Overrides, Flags] /** Use function `f` to compute value of field picked using `selector`. * @@ -84,7 +84,7 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags selector: To => T, f: From => U )(implicit ev: U <:< T): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withFieldComputedImpl[From, To, Cfg, Flags] + macro PartialTransformerIntoMacros.withFieldComputedImpl[From, To, Overrides, Flags] /** Use function `f` to compute partial result for field picked using `selector`. * @@ -104,7 +104,7 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags selector: To => T, f: From => partial.Result[U] )(implicit ev: U <:< T): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withFieldComputedPartialImpl[From, To, Cfg, Flags] + macro PartialTransformerIntoMacros.withFieldComputedPartialImpl[From, To, Overrides, Flags] /** Use `selectorFrom` field in `From` to obtain the value of `selectorTo` field in `To` * @@ -124,7 +124,7 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags selectorFrom: From => T, selectorTo: To => U ): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withFieldRenamedImpl[From, To, Cfg, Flags] + macro PartialTransformerIntoMacros.withFieldRenamedImpl[From, To, Overrides, Flags] /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another. * @@ -135,14 +135,16 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerInto]] * * @since 0.7.0 */ - def withCoproductInstance[Inst](f: Inst => To): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withCoproductInstanceImpl[From, To, Cfg, Flags, Inst] + def withCoproductInstance[Subtype]( + f: Subtype => To + ): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = + macro PartialTransformerIntoMacros.withCoproductInstanceImpl[From, To, Overrides, Flags, Subtype] /** Use `f` to calculate the (missing) coproduct instance partial result when mapping one coproduct into another. * @@ -153,16 +155,16 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerInto]] * * @since 0.7.0 */ - def withCoproductInstancePartial[Inst]( - f: Inst => partial.Result[To] + def withCoproductInstancePartial[Subtype]( + f: Subtype => partial.Result[To] ): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withCoproductInstancePartialImpl[From, To, Cfg, Flags, Inst] + macro PartialTransformerIntoMacros.withCoproductInstancePartialImpl[From, To, Overrides, Flags, Subtype] /** Use `f` instead of the primary constructor to construct the `To` value. * @@ -181,7 +183,7 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags def withConstructor[Ctor]( f: Ctor )(implicit ev: IsFunction.Of[Ctor, To]): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withConstructorImpl[From, To, Cfg, Flags] + macro PartialTransformerIntoMacros.withConstructorImpl[From, To, Overrides, Flags] /** Use `f` instead of the primary constructor to parse into `partial.Result[To]` value. * @@ -202,13 +204,12 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags )(implicit ev: IsFunction.Of[Ctor, partial.Result[To]] ): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro PartialTransformerIntoMacros.withConstructorPartialImpl[From, To, Cfg, Flags] + macro PartialTransformerIntoMacros.withConstructorPartialImpl[From, To, Overrides, Flags] /** Apply configured partial transformation in-place. * - * It runs macro that tries to derive instance of `PartialTransformer[From, To]` - * and immediately apply it to captured `source` value. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `PartialTransformer[From, To]` and immediately apply it to captured + * `source` value. When transformation can't be derived, it results with compilation error. * * @return partial transformation result of type `partial.Result[To]` * @@ -217,13 +218,13 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags def transform[ImplicitScopeFlags <: TransformerFlags](implicit tc: io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags] ): partial.Result[To] = - macro TransformerMacros.derivePartialTransformationWithConfigNoFailFast[From, To, Cfg, Flags, ImplicitScopeFlags] + macro TransformerMacros + .derivePartialTransformationWithConfigNoFailFast[From, To, Overrides, Flags, ImplicitScopeFlags] /** Apply configured partial transformation in-place in a short-circuit (fail fast) mode. * - * It runs macro that tries to derive instance of `PartialTransformer[From, To]` - * and immediately apply it to captured `source` value. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `PartialTransformer[From, To]` and immediately apply it to captured + * `source` value. When transformation can't be derived, it results with compilation error. * * @return partial transformation result of type `partial.Result[To]` * @@ -232,7 +233,8 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags def transformFailFast[ImplicitScopeFlags <: TransformerFlags](implicit tc: io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags] ): partial.Result[To] = - macro TransformerMacros.derivePartialTransformationWithConfigFailFast[From, To, Cfg, Flags, ImplicitScopeFlags] + macro TransformerMacros + .derivePartialTransformationWithConfigFailFast[From, To, Overrides, Flags, ImplicitScopeFlags] private[chimney] def addOverride(overrideData: Any): this.type = new PartialTransformerInto(source, td.addOverride(overrideData)).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherDefinition.scala b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherDefinition.scala index f3275e90b..edfac63bc 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherDefinition.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherDefinition.scala @@ -8,16 +8,16 @@ import scala.language.experimental.macros /** Allows customization of [[io.scalaland.chimney.Patcher]] derivation. * - * @tparam A type of object to apply patch to - * @tparam Patch type of patch object - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam A type of object to apply patch to + * @tparam Patch type of patch object + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * * @since 0.8.0 */ -final class PatcherDefinition[From, To, Cfg <: PatcherOverrides, Flags <: PatcherFlags] +final class PatcherDefinition[From, To, Overrides <: PatcherOverrides, Flags <: PatcherFlags] extends PatcherFlagsDsl[Lambda[ - `Flags1 <: PatcherFlags` => PatcherDefinition[From, To, Cfg, Flags1] + `Flags1 <: PatcherFlags` => PatcherDefinition[From, To, Overrides, Flags1] ], Flags] { /** Build Patcher using current configuration. @@ -32,5 +32,5 @@ final class PatcherDefinition[From, To, Cfg <: PatcherOverrides, Flags <: Patche def buildPatcher[ImplicitScopeFlags <: PatcherFlags](implicit tc: io.scalaland.chimney.dsl.PatcherConfiguration[ImplicitScopeFlags] ): Patcher[From, To] = - macro PatcherMacros.derivePatcherWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags] + macro PatcherMacros.derivePatcherWithConfig[From, To, Overrides, Flags, ImplicitScopeFlags] } diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherUsing.scala b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherUsing.scala index 61959c452..2fbd865dd 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherUsing.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/PatcherUsing.scala @@ -5,22 +5,23 @@ import io.scalaland.chimney.internal.runtime.{PatcherFlags, PatcherOverrides} import scala.language.experimental.macros -/** Provides operations to customize [[io.scalaland.chimney.Patcher]] logic for specific - * object value and patch value. +/** Provides operations to customize [[io.scalaland.chimney.Patcher]] logic for specific object value and patch value. * - * @tparam A type of object to apply patch to - * @tparam Patch type of patch object - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam A type of object to apply patch to + * @tparam Patch type of patch object + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * @param obj object to patch * @param objPatch patch object * * @since 0.4.0 */ -final class PatcherUsing[A, Patch, Cfg <: PatcherOverrides, Flags <: PatcherFlags](val obj: A, val objPatch: Patch) - extends PatcherFlagsDsl[Lambda[`Flags1 <: PatcherFlags` => PatcherUsing[A, Patch, Cfg, Flags1]], Flags] { +final class PatcherUsing[A, Patch, Overrides <: PatcherOverrides, Flags <: PatcherFlags]( + val obj: A, + val objPatch: Patch +) extends PatcherFlagsDsl[Lambda[`Flags1 <: PatcherFlags` => PatcherUsing[A, Patch, Overrides, Flags1]], Flags] { - /** Applies configured patching in-place + /** Applies configured patching in-place. * * @return patched value * @@ -28,5 +29,5 @@ final class PatcherUsing[A, Patch, Cfg <: PatcherOverrides, Flags <: PatcherFlag */ def patch[ImplicitScopeFlags <: PatcherFlags](implicit tc: PatcherConfiguration[ImplicitScopeFlags] - ): A = macro PatcherMacros.derivePatchWithConfig[A, Patch, Cfg, Flags, ImplicitScopeFlags] + ): A = macro PatcherMacros.derivePatchWithConfig[A, Patch, Overrides, Flags, ImplicitScopeFlags] } diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinition.scala b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinition.scala index 4024cacd6..e221e81e0 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinition.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinition.scala @@ -9,32 +9,31 @@ import scala.language.experimental.macros /** Allows customization of [[io.scalaland.chimney.Transformer]] derivation. * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * * @since 0.4.0 */ -final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class TransformerDefinition[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val runtimeData: TransformerDefinitionCommons.RuntimeDataStore ) extends TransformerFlagsDsl[Lambda[ - `Flags1 <: TransformerFlags` => TransformerDefinition[From, To, Cfg, Flags1] + `Flags1 <: TransformerFlags` => TransformerDefinition[From, To, Overrides, Flags1] ], Flags] with TransformerDefinitionCommons[ - Lambda[`Cfg1 <: TransformerOverrides` => TransformerDefinition[From, To, Cfg1, Flags]] + Lambda[`Overrides1 <: TransformerOverrides` => TransformerDefinition[From, To, Overrides1, Flags]] ] with WithRuntimeDataStore { - /** Lifts current transformer definition as `PartialTransformer` definition + /** Lifts current transformer definition as `PartialTransformer` definition. * - * It keeps all the configuration, provided missing values, renames, - * coproduct instances etc. + * It keeps all the configuration, provided missing values, renames, coproduct instances etc. * * @return [[io.scalaland.chimney.dsl.PartialTransformerDefinition]] */ - def partial: PartialTransformerDefinition[From, To, Cfg, Flags] = - new PartialTransformerDefinition[From, To, Cfg, Flags](runtimeData) + def partial: PartialTransformerDefinition[From, To, Overrides, Flags] = + new PartialTransformerDefinition[From, To, Overrides, Flags](runtimeData) /** Use provided value `value` for field picked using `selector`. * @@ -53,7 +52,7 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < def withFieldConst[T, U](selector: To => T, value: U)(implicit ev: U <:< T ): TransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerDefinitionMacros.withFieldConstImpl[From, To, Cfg, Flags] + macro TransformerDefinitionMacros.withFieldConstImpl[From, To, Overrides, Flags] /** Use function `f` to compute value of field picked using `selector`. * @@ -73,7 +72,7 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < selector: To => T, f: From => U )(implicit ev: U <:< T): TransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerDefinitionMacros.withFieldComputedImpl[From, To, Cfg, Flags] + macro TransformerDefinitionMacros.withFieldComputedImpl[From, To, Overrides, Flags] /** Use `selectorFrom` field in `From` to obtain the value of `selectorTo` field in `To` * @@ -93,7 +92,7 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < selectorFrom: From => T, selectorTo: To => U ): TransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerDefinitionMacros.withFieldRenamedImpl[From, To, Cfg, Flags] + macro TransformerDefinitionMacros.withFieldRenamedImpl[From, To, Overrides, Flags] /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another. * @@ -104,14 +103,16 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.TransformerDefinition]] * * @since 0.4.0 */ - def withCoproductInstance[Inst](f: Inst => To): TransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerDefinitionMacros.withCoproductInstanceImpl[From, To, Cfg, Flags, Inst] + def withCoproductInstance[Subtype]( + f: Subtype => To + ): TransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = + macro TransformerDefinitionMacros.withCoproductInstanceImpl[From, To, Overrides, Flags, Subtype] /** Use `f` instead of the primary constructor to construct the `To` value. * @@ -130,7 +131,7 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < def withConstructor[Ctor]( f: Ctor )(implicit ev: IsFunction.Of[Ctor, To]): TransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerDefinitionMacros.withConstructorImpl[From, To, Cfg, Flags] + macro TransformerDefinitionMacros.withConstructorImpl[From, To, Overrides, Flags] /** Build Transformer using current configuration. * @@ -144,7 +145,7 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < def buildTransformer[ImplicitScopeFlags <: TransformerFlags](implicit tc: io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags] ): Transformer[From, To] = - macro TransformerMacros.deriveTotalTransformerWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags] + macro TransformerMacros.deriveTotalTransformerWithConfig[From, To, Overrides, Flags, ImplicitScopeFlags] private[chimney] def addOverride(overrideData: Any): this.type = new TransformerDefinition(overrideData +: runtimeData).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala index 2044c9fc0..0fcd03154 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala @@ -7,7 +7,7 @@ object TransformerDefinitionCommons { def emptyRuntimeDataStore: RuntimeDataStore = Vector.empty[Any] } -private[chimney] trait TransformerDefinitionCommons[UpdateCfg[_ <: TransformerOverrides]] { +private[chimney] trait TransformerDefinitionCommons[UpdateTail[_ <: TransformerOverrides]] { import TransformerDefinitionCommons.* diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerInto.scala b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerInto.scala index 4534a01c0..07c985589 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerInto.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/dsl/TransformerInto.scala @@ -6,33 +6,34 @@ import io.scalaland.chimney.internal.runtime.{IsFunction, TransformerFlags, Tran import scala.language.experimental.macros -/** Provides DSL for configuring [[io.scalaland.chimney.Transformer]]'s - * generation and using the result to transform value at the same time +/** Provides DSL for configuring [[io.scalaland.chimney.Transformer]]'s generation and using the result to transform + * value at the same time * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * @param source object to transform * @param td transformer definition * * @since 0.1.0 */ -final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class TransformerInto[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val source: From, - val td: TransformerDefinition[From, To, Cfg, Flags] -) extends TransformerFlagsDsl[Lambda[`Flags1 <: TransformerFlags` => TransformerInto[From, To, Cfg, Flags1]], Flags] + val td: TransformerDefinition[From, To, Overrides, Flags] +) extends TransformerFlagsDsl[Lambda[ + `Flags1 <: TransformerFlags` => TransformerInto[From, To, Overrides, Flags1] + ], Flags] with WithRuntimeDataStore { /** Lifts current transformation as partial transformation. * - * It keeps all the configuration, provided missing values, renames, - * coproduct instances etc. + * It keeps all the configuration, provided missing values, renames, coproduct instances etc. * * @return [[io.scalaland.chimney.dsl.PartialTransformerInto]] */ - def partial: PartialTransformerInto[From, To, Cfg, Flags] = - new PartialTransformerInto[From, To, Cfg, Flags](source, td.partial) + def partial: PartialTransformerInto[From, To, Overrides, Flags] = + new PartialTransformerInto[From, To, Overrides, Flags](source, td.partial) /** Use `value` provided here for field picked using `selector`. * @@ -47,7 +48,7 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran def withFieldConst[T, U](selector: To => T, value: U)(implicit ev: U <:< T ): TransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerIntoMacros.withFieldConstImpl[From, To, Cfg, Flags] + macro TransformerIntoMacros.withFieldConstImpl[From, To, Overrides, Flags] /** Use function `f` to compute value of field picked using `selector`. * @@ -67,7 +68,7 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran selector: To => T, f: From => U )(implicit ev: U <:< T): TransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerIntoMacros.withFieldComputedImpl[From, To, Cfg, Flags] + macro TransformerIntoMacros.withFieldComputedImpl[From, To, Overrides, Flags] /** Use `selectorFrom` field in `From` to obtain the value of `selectorTo` field in `To` * @@ -87,7 +88,7 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran selectorFrom: From => T, selectorTo: To => U ): TransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerIntoMacros.withFieldRenamedImpl[From, To, Cfg, Flags] + macro TransformerIntoMacros.withFieldRenamedImpl[From, To, Overrides, Flags] /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another * @@ -98,13 +99,13 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance@param f function to calculate values of components that cannot be mapped automatically + * @tparam Subtypetype of coproduct instance@param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.TransformerInto]] * * @since 0.1.2 */ - def withCoproductInstance[Inst](f: Inst => To): TransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerIntoMacros.withCoproductInstanceImpl[From, To, Cfg, Flags, Inst] + def withCoproductInstance[Subtype](f: Subtype => To): TransformerInto[From, To, ? <: TransformerOverrides, Flags] = + macro TransformerIntoMacros.withCoproductInstanceImpl[From, To, Overrides, Flags, Subtype] /** Use `f` instead of the primary constructor to construct the `To` value. * @@ -123,7 +124,7 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran def withConstructor[Ctor]( f: Ctor )(implicit ev: IsFunction.Of[Ctor, To]): TransformerInto[From, To, ? <: TransformerOverrides, Flags] = - macro TransformerIntoMacros.withConstructorImpl[From, To, Cfg, Flags] + macro TransformerIntoMacros.withConstructorImpl[From, To, Overrides, Flags] /** Apply configured transformation in-place. * @@ -138,7 +139,7 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran def transform[ImplicitScopeFlags <: TransformerFlags](implicit tc: io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags] ): To = - macro TransformerMacros.deriveTotalTransformationWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags] + macro TransformerMacros.deriveTotalTransformationWithConfig[From, To, Overrides, Flags, ImplicitScopeFlags] private[chimney] def addOverride(overrideData: Any): this.type = new TransformerInto(source, td.addOverride(overrideData)).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala index 8fe6e3638..996167b08 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala @@ -34,15 +34,15 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi def fixJavaEnums(path: ?<[runtime.Path]): ?<[runtime.Path] = path.Underlying match { case root if root =:= Path.Root => path - case Path.Select(name, instance) => - val fixedInstance = fixJavaEnums(instance) - import name.Underlying as Name, fixedInstance.Underlying as FixedInstance - Path.Select.apply(Name, FixedInstance).as_?<[runtime.Path] - case Path.Match(subtype, instance) => + case Path.Select(init, name) => + val fixedInit = fixJavaEnums(init) + import name.Underlying as Name, fixedInit.Underlying as FixedInit + Path.Select[FixedInit, Name].as_?<[runtime.Path] + case Path.Match(init, subtype) => val fixedSubtype = fixJavaEnum(subtype) - val fixedInstance = fixJavaEnums(instance) - import fixedSubtype.Underlying as FixedSubtype, fixedInstance.Underlying as FixedInstance - Path.Match.apply(FixedSubtype, FixedInstance).as_?<[runtime.Path] + val fixedInit = fixJavaEnums(init) + import fixedSubtype.Underlying as FixedSubtype, fixedInit.Underlying as FixedInit + Path.Match[FixedInit, FixedSubtype].as_?<[runtime.Path] case _ => reportError(s"Expected valid runtime.Path, got ${Type.prettyPrint(path.Underlying)}") } } @@ -111,54 +111,54 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi object TransformerOverrides extends TransformerOverridesModule { val Empty: Type[runtime.TransformerOverrides.Empty] = weakTypeTag[runtime.TransformerOverrides.Empty] object Const extends ConstModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.Const[ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.Const[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.Const[ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.Const[ToPath, Tail]] def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = if (A.isCtor[runtime.TransformerOverrides.Const[?, ?]]) Some(fixJavaEnums(A.param_<[runtime.Path](0)) -> A.param_<[runtime.TransformerOverrides](1)) else scala.None } object ConstPartial extends ConstPartialModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.ConstPartial[ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.ConstPartial[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.ConstPartial[ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.ConstPartial[ToPath, Tail]] def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = if (A.isCtor[runtime.TransformerOverrides.ConstPartial[?, ?]]) Some(fixJavaEnums(A.param_<[runtime.Path](0)) -> A.param_<[runtime.TransformerOverrides](1)) else scala.None } object Computed extends ComputedModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.Computed[ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.Computed[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.Computed[ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.Computed[ToPath, Tail]] def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = if (A.isCtor[runtime.TransformerOverrides.Computed[?, ?]]) Some(fixJavaEnums(A.param_<[runtime.Path](0)) -> A.param_<[runtime.TransformerOverrides](1)) else scala.None } object ComputedPartial extends ComputedPartialModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.ComputedPartial[ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.ComputedPartial[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.ComputedPartial[ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.ComputedPartial[ToPath, Tail]] def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = if (A.isCtor[runtime.TransformerOverrides.ComputedPartial[?, ?]]) Some(fixJavaEnums(A.param_<[runtime.Path](0)) -> A.param_<[runtime.TransformerOverrides](1)) else scala.None } object CaseComputed extends CaseComputedModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.CaseComputed[ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.CaseComputed[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.CaseComputed[ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.CaseComputed[ToPath, Tail]] def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = if (A.isCtor[runtime.TransformerOverrides.CaseComputed[?, ?]]) Some(fixJavaEnums(A.param_<[runtime.Path](0)) -> A.param_<[runtime.TransformerOverrides](1)) else scala.None } object CaseComputedPartial extends CaseComputedPartialModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Tail]] def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = if (A.isCtor[runtime.TransformerOverrides.CaseComputedPartial[?, ?]]) Some(fixJavaEnums(A.param_<[runtime.Path](0)) -> A.param_<[runtime.TransformerOverrides](1)) @@ -168,9 +168,9 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi def apply[ Args <: runtime.ArgumentLists: Type, ToPath <: runtime.Path: Type, - Cfg <: runtime.TransformerOverrides: Type - ]: Type[runtime.TransformerOverrides.Constructor[Args, ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.Constructor[Args, ToPath, Cfg]] + Tail <: runtime.TransformerOverrides: Type + ]: Type[runtime.TransformerOverrides.Constructor[Args, ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.Constructor[Args, ToPath, Tail]] def unapply[A]( A: Type[A] ): Option[(?<[runtime.ArgumentLists], ?<[runtime.Path], ?<[runtime.TransformerOverrides])] = @@ -188,9 +188,9 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi def apply[ Args <: runtime.ArgumentLists: Type, ToPath <: runtime.Path: Type, - Cfg <: runtime.TransformerOverrides: Type - ]: Type[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Cfg]] + Tail <: runtime.TransformerOverrides: Type + ]: Type[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Tail]] def unapply[A]( A: Type[A] ): Option[(?<[runtime.ArgumentLists], ?<[runtime.Path], ?<[runtime.TransformerOverrides])] = @@ -208,9 +208,9 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi def apply[ FromPath <: runtime.Path: Type, ToPath <: runtime.Path: Type, - Cfg <: runtime.TransformerOverrides: Type - ]: Type[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Cfg]] = - weakTypeTag[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Cfg]] + Tail <: runtime.TransformerOverrides: Type + ]: Type[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Tail]] = + weakTypeTag[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Tail]] def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[runtime.Path], ?<[runtime.TransformerOverrides])] = if (A.isCtor[runtime.TransformerOverrides.RenamedFrom[?, ?, ?]]) Some( @@ -334,17 +334,17 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi object Path extends PathModule { val Root: Type[runtime.Path.Root] = weakTypeTag[runtime.Path.Root] object Select extends SelectModule { - def apply[Name <: String: Type, Instance <: runtime.Path: Type]: Type[runtime.Path.Select[Name, Instance]] = - weakTypeTag[runtime.Path.Select[Name, Instance]] - def unapply[A](A: Type[A]): Option[(?<[String], ?<[runtime.Path])] = - if (A.isCtor[runtime.Path.Select[?, ?]]) Some(A.param_<[String](0) -> A.param_<[runtime.Path](1)) + def apply[Init <: runtime.Path: Type, FieldName <: String: Type]: Type[runtime.Path.Select[Init, FieldName]] = + weakTypeTag[runtime.Path.Select[Init, FieldName]] + def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ?<[String])] = + if (A.isCtor[runtime.Path.Select[?, ?]]) Some(A.param_<[runtime.Path](0) -> A.param_<[String](1)) else scala.None } object Match extends MatchModule { - def apply[Subtype: Type, Instance <: runtime.Path: Type]: Type[runtime.Path.Match[Subtype, Instance]] = - weakTypeTag[runtime.Path.Match[Subtype, Instance]] - def unapply[A](A: Type[A]): Option[(??, ?<[runtime.Path])] = - if (A.isCtor[runtime.Path.Match[?, ?]]) Some(A.param(0) -> A.param_<[runtime.Path](1)) + def apply[Init <: runtime.Path: Type, Subtype: Type]: Type[runtime.Path.Match[Init, Subtype]] = + weakTypeTag[runtime.Path.Match[Init, Subtype]] + def unapply[A](A: Type[A]): Option[(?<[runtime.Path], ??)] = + if (A.isCtor[runtime.Path.Match[?, ?]]) Some(A.param_<[runtime.Path](0) -> A.param(1)) else scala.None } } diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala index 99eb1a894..09f85f3a8 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala @@ -12,17 +12,17 @@ final class PatcherMacros(val c: blackbox.Context) extends DerivationPlatform wi def derivePatchWithConfig[ A: WeakTypeTag, Patch: WeakTypeTag, - Cfg <: runtime.PatcherOverrides: WeakTypeTag, + Tail <: runtime.PatcherOverrides: WeakTypeTag, Flags <: runtime.PatcherFlags: WeakTypeTag, ImplicitScopeFlags <: runtime.PatcherFlags: WeakTypeTag ]( tc: Expr[io.scalaland.chimney.dsl.PatcherConfiguration[ImplicitScopeFlags]] ): c.Expr[A] = retypecheck( // Called by PatcherUsing => prefix is PatcherUsing - cacheDefinition(c.Expr[dsl.PatcherUsing[A, Patch, Cfg, Flags]](c.prefix.tree)) { pu => + cacheDefinition(c.Expr[dsl.PatcherUsing[A, Patch, Tail, Flags]](c.prefix.tree)) { pu => Expr.block( List(Expr.suppressUnused(pu)), - derivePatcherResult[A, Patch, Cfg, Flags, ImplicitScopeFlags]( + derivePatcherResult[A, Patch, Tail, Flags, ImplicitScopeFlags]( obj = c.Expr[A](q"$pu.obj"), patch = c.Expr[Patch](q"$pu.objPatch") ) @@ -33,16 +33,16 @@ final class PatcherMacros(val c: blackbox.Context) extends DerivationPlatform wi def derivePatcherWithConfig[ A: WeakTypeTag, Patch: WeakTypeTag, - Cfg <: runtime.PatcherOverrides: WeakTypeTag, + Tail <: runtime.PatcherOverrides: WeakTypeTag, InstanceFlags <: runtime.PatcherFlags: WeakTypeTag, ImplicitScopeFlags <: runtime.PatcherFlags: WeakTypeTag ]( tc: Expr[io.scalaland.chimney.dsl.PatcherConfiguration[ImplicitScopeFlags]] ): Expr[Patcher[A, Patch]] = retypecheck( - cacheDefinition(c.Expr[dsl.PatcherDefinition[A, Patch, Cfg, InstanceFlags]](c.prefix.tree)) { pu => + cacheDefinition(c.Expr[dsl.PatcherDefinition[A, Patch, Tail, InstanceFlags]](c.prefix.tree)) { pu => Expr.block( List(Expr.suppressUnused(pu)), - derivePatcher[A, Patch, Cfg, InstanceFlags, ImplicitScopeFlags] + derivePatcher[A, Patch, Tail, InstanceFlags, ImplicitScopeFlags] ) } ) diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala index 37116b0d0..522763a9a 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala @@ -14,7 +14,7 @@ final class TransformerMacros(val c: blackbox.Context) extends DerivationPlatfor def deriveTotalTransformationWithConfig[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: runtime.TransformerOverrides: WeakTypeTag, + Tail <: runtime.TransformerOverrides: WeakTypeTag, InstanceFlags <: runtime.TransformerFlags: WeakTypeTag, ImplicitScopeFlags <: runtime.TransformerFlags: WeakTypeTag ]( @@ -22,10 +22,10 @@ final class TransformerMacros(val c: blackbox.Context) extends DerivationPlatfor ): Expr[To] = retypecheck( // Called by TransformerInto => prefix is TransformerInto // We're caching it because it is used twice: once for RuntimeDataStore and once for source - cacheDefinition(c.Expr[dsl.TransformerInto[From, To, Cfg, InstanceFlags]](c.prefix.tree)) { ti => + cacheDefinition(c.Expr[dsl.TransformerInto[From, To, Tail, InstanceFlags]](c.prefix.tree)) { ti => Expr.block( List(Expr.suppressUnused(tc)), - deriveTotalTransformationResult[From, To, Cfg, InstanceFlags, ImplicitScopeFlags]( + deriveTotalTransformationResult[From, To, Tail, InstanceFlags, ImplicitScopeFlags]( src = c.Expr[From](q"$ti.source"), runtimeDataStore = c.Expr[dsl.TransformerDefinitionCommons.RuntimeDataStore](q"$ti.td.runtimeData") ) @@ -52,14 +52,14 @@ final class TransformerMacros(val c: blackbox.Context) extends DerivationPlatfor def deriveTotalTransformerWithConfig[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: runtime.TransformerOverrides: WeakTypeTag, + Tail <: runtime.TransformerOverrides: WeakTypeTag, InstanceFlags <: runtime.TransformerFlags: WeakTypeTag, ImplicitScopeFlags <: runtime.TransformerFlags: WeakTypeTag ](tc: Expr[io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags]]): Expr[Transformer[From, To]] = retypecheck( Expr.block( List(Expr.suppressUnused(tc)), - deriveTotalTransformer[From, To, Cfg, InstanceFlags, ImplicitScopeFlags]( + deriveTotalTransformer[From, To, Tail, InstanceFlags, ImplicitScopeFlags]( // Called by TransformerDefinition => prefix is TransformerDefinition c.Expr[dsl.TransformerDefinitionCommons.RuntimeDataStore](q"${c.prefix.tree}.runtimeData") ) @@ -69,17 +69,17 @@ final class TransformerMacros(val c: blackbox.Context) extends DerivationPlatfor def derivePartialTransformationWithConfigNoFailFast[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: runtime.TransformerOverrides: WeakTypeTag, + Tail <: runtime.TransformerOverrides: WeakTypeTag, InstanceFlags <: runtime.TransformerFlags: WeakTypeTag, ImplicitScopeFlags <: runtime.TransformerFlags: WeakTypeTag ](tc: Expr[io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags]]): Expr[partial.Result[To]] = retypecheck( // Called by PartialTransformerInto => prefix is PartialTransformerInto // We're caching it because it is used twice: once for RuntimeDataStore and once for source - cacheDefinition(c.Expr[dsl.PartialTransformerInto[From, To, Cfg, InstanceFlags]](c.prefix.tree)) { pti => + cacheDefinition(c.Expr[dsl.PartialTransformerInto[From, To, Tail, InstanceFlags]](c.prefix.tree)) { pti => Expr.block( List(Expr.suppressUnused(tc)), - derivePartialTransformationResult[From, To, Cfg, InstanceFlags, ImplicitScopeFlags]( + derivePartialTransformationResult[From, To, Tail, InstanceFlags, ImplicitScopeFlags]( src = c.Expr[From](q"$pti.source"), failFast = c.Expr[Boolean](q"false"), runtimeDataStore = c.Expr[dsl.TransformerDefinitionCommons.RuntimeDataStore](q"$pti.td.runtimeData") @@ -91,17 +91,17 @@ final class TransformerMacros(val c: blackbox.Context) extends DerivationPlatfor def derivePartialTransformationWithConfigFailFast[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: runtime.TransformerOverrides: WeakTypeTag, + Tail <: runtime.TransformerOverrides: WeakTypeTag, InstanceFlags <: runtime.TransformerFlags: WeakTypeTag, ImplicitScopeFlags <: runtime.TransformerFlags: WeakTypeTag ](tc: Expr[io.scalaland.chimney.dsl.TransformerConfiguration[ImplicitScopeFlags]]): Expr[partial.Result[To]] = retypecheck( // Called by PartialTransformerInto => prefix is PartialTransformerInto // We're caching it because it is used twice: once for RuntimeDataStore and once for source - cacheDefinition(c.Expr[dsl.PartialTransformerInto[From, To, Cfg, InstanceFlags]](c.prefix.tree)) { pti => + cacheDefinition(c.Expr[dsl.PartialTransformerInto[From, To, Tail, InstanceFlags]](c.prefix.tree)) { pti => Expr.block( List(Expr.suppressUnused(tc)), - derivePartialTransformationResult[From, To, Cfg, InstanceFlags, ImplicitScopeFlags]( + derivePartialTransformationResult[From, To, Tail, InstanceFlags, ImplicitScopeFlags]( src = c.Expr[From](q"$pti.source"), failFast = c.Expr[Boolean](q"true"), runtimeDataStore = c.Expr[dsl.TransformerDefinitionCommons.RuntimeDataStore](q"$pti.td.runtimeData") @@ -130,7 +130,7 @@ final class TransformerMacros(val c: blackbox.Context) extends DerivationPlatfor def derivePartialTransformerWithConfig[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: runtime.TransformerOverrides: WeakTypeTag, + Tail <: runtime.TransformerOverrides: WeakTypeTag, InstanceFlags <: runtime.TransformerFlags: WeakTypeTag, ImplicitScopeFlags <: runtime.TransformerFlags: WeakTypeTag ]( @@ -138,7 +138,7 @@ final class TransformerMacros(val c: blackbox.Context) extends DerivationPlatfor ): Expr[PartialTransformer[From, To]] = retypecheck( Expr.block( List(Expr.suppressUnused(tc)), - derivePartialTransformer[From, To, Cfg, InstanceFlags, ImplicitScopeFlags]( + derivePartialTransformer[From, To, Tail, InstanceFlags, ImplicitScopeFlags]( // Called by PartialTransformerDefinition => prefix is PartialTransformerDefinition c.Expr[dsl.TransformerDefinitionCommons.RuntimeDataStore](q"${c.prefix.tree}.runtimeData") ) diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala index ac9645d14..b201c3847 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala @@ -14,124 +14,124 @@ class PartialTransformerDefinitionMacros(val c: whitebox.Context) extends utils. def withFieldConstImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, value: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(value) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerDefinition[From, To, Const[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerDefinition[From, To, Const[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldConstPartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, value: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(value) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerDefinition[From, To, ConstPartial[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerDefinition[From, To, ConstPartial[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldComputedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, f: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerDefinition[From, To, Computed[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerDefinition[From, To, Computed[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldComputedPartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, f: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerDefinition[From, To, ComputedPartial[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerDefinition[From, To, ComputedPartial[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldRenamedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selectorFrom: Tree, selectorTo: Tree): Tree = c.prefix.tree .asInstanceOfExpr( new ApplyFieldNameTypes { def apply[FromPath <: Path: WeakTypeTag, ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerDefinition[From, To, RenamedFrom[FromPath, ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerDefinition[From, To, RenamedFrom[FromPath, ToPath, Overrides], Flags]] }.applyFromSelectors(selectorFrom, selectorTo) ) def withCoproductInstanceImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag, - Inst: WeakTypeTag + Subtype: WeakTypeTag ](f: Tree): Tree = new ApplyFixedCoproductType { - def apply[FixedInstance: WeakTypeTag]: Tree = c.prefix.tree + def apply[FixedSubtype: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr[PartialTransformerDefinition[ From, To, - CaseComputed[Path.Match[FixedInstance, Path.Root], Cfg], + CaseComputed[Path.Match[Path.Root, FixedSubtype], Overrides], Flags ]] - }.applyJavaEnumFixFromClosureSignature[Inst](f) + }.applyJavaEnumFixFromClosureSignature[Subtype](f) def withCoproductInstancePartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag, - Inst: WeakTypeTag + Subtype: WeakTypeTag ](f: Tree): Tree = new ApplyFixedCoproductType { - def apply[FixedInstance: WeakTypeTag]: Tree = c.prefix.tree + def apply[FixedSubtype: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr[PartialTransformerDefinition[ From, To, - CaseComputedPartial[Path.Match[FixedInstance, Path.Root], Cfg], + CaseComputedPartial[Path.Match[Path.Root, FixedSubtype], Overrides], Flags ]] - }.applyJavaEnumFixFromClosureSignature[Inst](f) + }.applyJavaEnumFixFromClosureSignature[Subtype](f) def withConstructorImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](f: Tree)(@unused ev: Tree): Tree = new ApplyConstructorType { def apply[Args <: ArgumentLists: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[PartialTransformerDefinition[From, To, Constructor[Args, Path.Root, Cfg], Flags]] + .asInstanceOfExpr[PartialTransformerDefinition[From, To, Constructor[Args, Path.Root, Overrides], Flags]] }.applyFromBody(f) def withConstructorPartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](f: Tree)(@unused ev: Tree): Tree = new ApplyConstructorType { def apply[Args <: ArgumentLists: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[PartialTransformerDefinition[From, To, ConstructorPartial[Args, Path.Root, Cfg], Flags]] + .asInstanceOfExpr[PartialTransformerDefinition[From, To, ConstructorPartial[Args, Path.Root, Overrides], Flags]] }.applyFromBody(f) } diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala index b4be4d600..f5b5d1ec2 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala @@ -14,125 +14,125 @@ class PartialTransformerIntoMacros(val c: whitebox.Context) extends utils.DslMac def withFieldConstImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, value: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(value) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerInto[From, To, Const[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerInto[From, To, Const[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldConstPartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, value: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(value) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerInto[From, To, ConstPartial[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerInto[From, To, ConstPartial[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldComputedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, f: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerInto[From, To, Computed[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerInto[From, To, Computed[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldComputedPartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, f: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerInto[From, To, ComputedPartial[ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerInto[From, To, ComputedPartial[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldRenamedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selectorFrom: Tree, selectorTo: Tree): Tree = c.prefix.tree .asInstanceOfExpr( new ApplyFieldNameTypes { def apply[FromPath <: Path: WeakTypeTag, ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[PartialTransformerInto[From, To, RenamedFrom[FromPath, ToPath, Cfg], Flags]] + weakTypeTag[PartialTransformerInto[From, To, RenamedFrom[FromPath, ToPath, Overrides], Flags]] }.applyFromSelectors(selectorFrom, selectorTo) ) def withCoproductInstanceImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag, - Inst: WeakTypeTag + Subtype: WeakTypeTag ](f: Tree): Tree = new ApplyFixedCoproductType { - def apply[FixedInstance: WeakTypeTag]: Tree = c.prefix.tree + def apply[FixedSubtype: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr[PartialTransformerInto[ From, To, - CaseComputed[Path.Match[FixedInstance, Path.Root], Cfg], + CaseComputed[Path.Match[Path.Root, FixedSubtype], Overrides], Flags ]] - }.applyJavaEnumFixFromClosureSignature[Inst](f) + }.applyJavaEnumFixFromClosureSignature[Subtype](f) def withCoproductInstancePartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag, - Inst: WeakTypeTag + Subtype: WeakTypeTag ](f: Tree): Tree = new ApplyFixedCoproductType { - def apply[FixedInstance: WeakTypeTag]: Tree = c.prefix.tree + def apply[FixedSubtype: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr[PartialTransformerInto[ From, To, - CaseComputedPartial[Path.Match[FixedInstance, Path.Root], Cfg], + CaseComputedPartial[Path.Match[Path.Root, FixedSubtype], Overrides], Flags ]] - }.applyJavaEnumFixFromClosureSignature[Inst](f) + }.applyJavaEnumFixFromClosureSignature[Subtype](f) def withConstructorImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](f: Tree)(@unused ev: Tree): Tree = new ApplyConstructorType { def apply[Args <: ArgumentLists: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[PartialTransformerInto[From, To, Constructor[Args, Path.Root, Cfg], Flags]] + .asInstanceOfExpr[PartialTransformerInto[From, To, Constructor[Args, Path.Root, Overrides], Flags]] }.applyFromBody(f) def withConstructorPartialImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](f: Tree)(@unused ev: Tree): Tree = new ApplyConstructorType { def apply[Args <: ArgumentLists: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[PartialTransformerInto[From, To, ConstructorPartial[Args, Path.Root, Cfg], Flags]] + .asInstanceOfExpr[PartialTransformerInto[From, To, ConstructorPartial[Args, Path.Root, Overrides], Flags]] }.applyFromBody(f) } diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala index c59ee906a..1b390481a 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala @@ -14,64 +14,69 @@ class TransformerDefinitionMacros(val c: whitebox.Context) extends utils.DslMacr def withFieldConstImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, value: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(value) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[TransformerDefinition[From, To, Const[ToPath, Cfg], Flags]] + weakTypeTag[TransformerDefinition[From, To, Const[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldComputedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, f: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[TransformerDefinition[From, To, Computed[ToPath, Cfg], Flags]] + weakTypeTag[TransformerDefinition[From, To, Computed[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldRenamedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selectorFrom: Tree, selectorTo: Tree): Tree = c.prefix.tree .asInstanceOfExpr( new ApplyFieldNameTypes { def apply[FromPath <: Path: WeakTypeTag, ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[TransformerDefinition[From, To, RenamedFrom[FromPath, ToPath, Cfg], Flags]] + weakTypeTag[TransformerDefinition[From, To, RenamedFrom[FromPath, ToPath, Overrides], Flags]] }.applyFromSelectors(selectorFrom, selectorTo) ) def withCoproductInstanceImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag, - Inst: WeakTypeTag + Subtype: WeakTypeTag ](f: Tree): Tree = new ApplyFixedCoproductType { - def apply[FixedInstance: WeakTypeTag]: Tree = c.prefix.tree + def apply[FixedSubtype: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[TransformerDefinition[From, To, CaseComputed[Path.Match[FixedInstance, Path.Root], Cfg], Flags]] - }.applyJavaEnumFixFromClosureSignature[Inst](f) + .asInstanceOfExpr[TransformerDefinition[ + From, + To, + CaseComputed[Path.Match[Path.Root, FixedSubtype], Overrides], + Flags + ]] + }.applyJavaEnumFixFromClosureSignature[Subtype](f) def withConstructorImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](f: Tree)(@unused ev: Tree): Tree = new ApplyConstructorType { def apply[Args <: ArgumentLists: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[TransformerDefinition[From, To, Constructor[Args, Path.Root, Cfg], Flags]] + .asInstanceOfExpr[TransformerDefinition[From, To, Constructor[Args, Path.Root, Overrides], Flags]] }.applyFromBody(f) } diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala index 643a439fa..9257b189d 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala @@ -14,64 +14,64 @@ class TransformerIntoMacros(val c: whitebox.Context) extends utils.DslMacroUtils def withFieldConstImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, value: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(value) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[TransformerInto[From, To, Const[ToPath, Cfg], Flags]] + weakTypeTag[TransformerInto[From, To, Const[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldComputedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selector: Tree, f: Tree)(@unused ev: Tree): Tree = c.prefix.tree .addOverride(f) .asInstanceOfExpr( new ApplyFieldNameType { def apply[ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[TransformerInto[From, To, Computed[ToPath, Cfg], Flags]] + weakTypeTag[TransformerInto[From, To, Computed[ToPath, Overrides], Flags]] }.applyFromSelector(selector) ) def withFieldRenamedImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](selectorFrom: Tree, selectorTo: Tree): Tree = c.prefix.tree .asInstanceOfExpr( new ApplyFieldNameTypes { def apply[FromPath <: Path: WeakTypeTag, ToPath <: Path: WeakTypeTag]: c.WeakTypeTag[?] = - weakTypeTag[TransformerInto[From, To, RenamedFrom[FromPath, ToPath, Cfg], Flags]] + weakTypeTag[TransformerInto[From, To, RenamedFrom[FromPath, ToPath, Overrides], Flags]] }.applyFromSelectors(selectorFrom, selectorTo) ) def withCoproductInstanceImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag, - Inst: WeakTypeTag + Subtype: WeakTypeTag ](f: Tree): Tree = new ApplyFixedCoproductType { - def apply[FixedInstance: WeakTypeTag]: Tree = c.prefix.tree + def apply[FixedSubtype: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[TransformerInto[From, To, CaseComputed[Path.Match[FixedInstance, Path.Root], Cfg], Flags]] - }.applyJavaEnumFixFromClosureSignature[Inst](f) + .asInstanceOfExpr[TransformerInto[From, To, CaseComputed[Path.Match[Path.Root, FixedSubtype], Overrides], Flags]] + }.applyJavaEnumFixFromClosureSignature[Subtype](f) def withConstructorImpl[ From: WeakTypeTag, To: WeakTypeTag, - Cfg <: TransformerOverrides: WeakTypeTag, + Overrides <: TransformerOverrides: WeakTypeTag, Flags <: TransformerFlags: WeakTypeTag ](f: Tree)(@unused ev: Tree): Tree = new ApplyConstructorType { def apply[Args <: ArgumentLists: WeakTypeTag]: Tree = c.prefix.tree .addOverride(f) - .asInstanceOfExpr[TransformerInto[From, To, Constructor[Args, Path.Root, Cfg], Flags]] + .asInstanceOfExpr[TransformerInto[From, To, Constructor[Args, Path.Root, Overrides], Flags]] }.applyFromBody(f) } diff --git a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala index 9177b8844..35bf86966 100644 --- a/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala +++ b/chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala @@ -50,16 +50,16 @@ private[chimney] trait DslMacroUtils { case Apply(select @ Select(_, _), Nil) => unpackSelects(select) case Apply(_, _) => Left(arbitraryFunctionNotAllowed(t)) case Select(t2, fieldName: TermName) => - unpackSelects(t2).map { instance => + unpackSelects(t2).map { init => val name = ExistentialString(fieldName) - def applyTypes[FieldName <: String: c.WeakTypeTag, Instance <: runtime.Path: c.WeakTypeTag] = + def applyTypes[Init <: runtime.Path: c.WeakTypeTag, FieldName <: String: c.WeakTypeTag] = new ExistentialPath { - type Underlying = runtime.Path.Select[FieldName, Instance] - val Underlying: WeakTypeTag[runtime.Path.Select[FieldName, Instance]] = - weakTypeTag[runtime.Path.Select[FieldName, Instance]] + type Underlying = runtime.Path.Select[Init, FieldName] + val Underlying: WeakTypeTag[runtime.Path.Select[Init, FieldName]] = + weakTypeTag[runtime.Path.Select[Init, FieldName]] } - applyTypes(name.Underlying, instance.Underlying) + applyTypes(init.Underlying, name.Underlying) } case _ => Left(invalidSelectorErrorMessage(t)) } @@ -191,35 +191,35 @@ private[chimney] trait DslMacroUtils { /** Workaround for Java Enums, see [[io.scalaland.chimney.internal.runtime.RefinedJavaEnum]]. */ protected trait ApplyFixedCoproductType { - def apply[FixedInstance: WeakTypeTag]: Tree + def apply[FixedSubtype: WeakTypeTag]: Tree - final def applyJavaEnumFixFromClosureSignature[Inst: WeakTypeTag](f: Tree): Tree = - if (weakTypeOf[Inst].typeSymbol.isJavaEnum) { - val Inst = weakTypeOf[Inst] + final def applyJavaEnumFixFromClosureSignature[Subtype: WeakTypeTag](f: Tree): Tree = + if (weakTypeOf[Subtype].typeSymbol.isJavaEnum) { + val Subtype = weakTypeOf[Subtype] val Function(List(ValDef(_, _, lhs: TypeTree, _)), _) = f lhs.original match { // Java enum value in Scala 2.13 - case SingletonTypeTree(Literal(Constant(t: TermSymbol))) => apply(refineJavaEnum[Inst](t)) + case SingletonTypeTree(Literal(Constant(t: TermSymbol))) => apply(refineJavaEnum[Subtype](t)) // Java enum value in Scala 2.12 case SingletonTypeTree(Select(t, n)) if t.isTerm => - val t = Inst.companion.decls + val t = Subtype.companion.decls .find(_.name == n) .getOrElse( c.abort( c.enclosingPosition, - s"Can't find symbol `$n` among the declarations of `${Inst.typeSymbol.fullName}`" + s"Can't find symbol `$n` among the declarations of `${Subtype.typeSymbol.fullName}`" ) ) - apply(refineJavaEnum[Inst](t)) - case _ => apply(weakTypeTag[Inst]) + apply(refineJavaEnum[Subtype](t)) + case _ => apply(weakTypeTag[Subtype]) } - } else apply(weakTypeTag[Inst]) + } else apply(weakTypeTag[Subtype]) - private def refineJavaEnum[Inst: WeakTypeTag](t: Symbol): WeakTypeTag[?] = { + private def refineJavaEnum[Subtype: WeakTypeTag](t: Symbol): WeakTypeTag[?] = { object ApplyInstanceName { def apply[InstanceName <: String: WeakTypeTag] - : WeakTypeTag[io.scalaland.chimney.internal.runtime.RefinedJavaEnum[Inst, InstanceName]] = - weakTypeTag[io.scalaland.chimney.internal.runtime.RefinedJavaEnum[Inst, InstanceName]] + : WeakTypeTag[io.scalaland.chimney.internal.runtime.RefinedJavaEnum[Subtype, InstanceName]] = + weakTypeTag[io.scalaland.chimney.internal.runtime.RefinedJavaEnum[Subtype, InstanceName]] } ApplyInstanceName(c.WeakTypeTag(c.internal.constantType(Constant(t.name.decodedName.toString)))) diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala index c12d03cfe..84d0cff60 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerDefinition.scala @@ -6,21 +6,21 @@ import io.scalaland.chimney.internal.runtime.{IsFunction, TransformerFlags, Tran /** Allows customization of [[io.scalaland.chimney.PartialTransformer]] derivation. * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * * @since 0.7.0 */ -final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class PartialTransformerDefinition[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val runtimeData: TransformerDefinitionCommons.RuntimeDataStore ) extends TransformerFlagsDsl[ - [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Cfg, Flags1], + [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1], Flags ] with TransformerDefinitionCommons[ - [Cfg1 <: TransformerOverrides] =>> PartialTransformerDefinition[From, To, Cfg1, Flags] + [Overrides1 <: TransformerOverrides] =>> PartialTransformerDefinition[From, To, Overrides1, Flags] ] with WithRuntimeDataStore { @@ -126,21 +126,20 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another. * - * By default if mapping one coproduct in `From` into another coproduct in `To` derivation - * expects that coproducts to have matching names of its components, and for every component - * in `To` field's type there is matching component in `From` type. If some component is missing - * it fails compilation unless provided replacement with this operation. + * By default if mapping one coproduct in `From` into another coproduct in `To` derivation expects that coproducts + * to have matching names of its components, and for every component in `To` field's type there is matching component + * in `From` type. If some component is missing it fails compilation unless provided replacement with this operation. * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerDefinition]] * * @since 0.7.0 */ - transparent inline def withCoproductInstance[Inst]( - inline f: Inst => To + transparent inline def withCoproductInstance[Subtype]( + inline f: Subtype => To ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = ${ PartialTransformerDefinitionMacros.withCoproductInstance('this, 'f) } @@ -153,14 +152,14 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerDefinition]] * * @since 0.7.0 */ - transparent inline def withCoproductInstancePartial[Inst]( - inline f: Inst => partial.Result[To] + transparent inline def withCoproductInstancePartial[Subtype]( + inline f: Subtype => partial.Result[To] ): PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = ${ PartialTransformerDefinitionMacros.withCoproductInstancePartial('this, 'f) } @@ -206,8 +205,8 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, /** Build Partial Transformer using current configuration. * - * It runs macro that tries to derive instance of `PartialTransformer[From, To]`. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `PartialTransformer[From, To]`. When transformation can't + * be derived, it results with compilation error. * * @return [[io.scalaland.chimney.PartialTransformer]] type class instance * @@ -216,7 +215,7 @@ final class PartialTransformerDefinition[From, To, Cfg <: TransformerOverrides, inline def buildTransformer[ImplicitScopeFlags <: TransformerFlags](using tc: TransformerConfiguration[ImplicitScopeFlags] ): PartialTransformer[From, To] = - ${ PartialTransformerDefinitionMacros.buildTransformer[From, To, Cfg, Flags, ImplicitScopeFlags]('this) } + ${ PartialTransformerDefinitionMacros.buildTransformer[From, To, Overrides, Flags, ImplicitScopeFlags]('this) } private[chimney] def addOverride(overrideData: Any): this.type = new PartialTransformerDefinition(overrideData +: runtimeData).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerInto.scala b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerInto.scala index 4adb6b605..be1868440 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerInto.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PartialTransformerInto.scala @@ -5,22 +5,25 @@ import io.scalaland.chimney.partial import io.scalaland.chimney.internal.compiletime.dsl.PartialTransformerIntoMacros import io.scalaland.chimney.internal.runtime.{IsFunction, TransformerFlags, TransformerOverrides, WithRuntimeDataStore} -/** Provides DSL for configuring [[io.scalaland.chimney.PartialTransformer]]'s - * generation and using the result to transform value at the same time +/** Provides DSL for configuring [[io.scalaland.chimney.PartialTransformer]]'s generation and using the result + * to transform value at the same time * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * @param source object to transform * @param td transformer definition * * @since 0.7.0 */ -final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class PartialTransformerInto[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val source: From, - val td: PartialTransformerDefinition[From, To, Cfg, Flags] -) extends TransformerFlagsDsl[[Flags1 <: TransformerFlags] =>> PartialTransformerInto[From, To, Cfg, Flags1], Flags] + val td: PartialTransformerDefinition[From, To, Overrides, Flags] +) extends TransformerFlagsDsl[ + [Flags1 <: TransformerFlags] =>> PartialTransformerInto[From, To, Overrides, Flags1], + Flags + ] with WithRuntimeDataStore { /** Use provided `value` for field picked using `selector`. @@ -125,41 +128,39 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another. * - * By default if mapping one coproduct in `From` into another coproduct in `To` derivation - * expects that coproducts to have matching names of its components, and for every component - * in `To` field's type there is matching component in `From` type. If some component is missing - * it fails compilation unless provided replacement with this operation. + * By default if mapping one coproduct in `From` into another coproduct in `To` derivation expects that coproducts + * to have matching names of its components, and for every component in `To` field's type there is matching component + * in `From` type. If some component is missing it fails compilation unless provided replacement with this operation. * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerInto]] * * @since 0.7.0 */ - transparent inline def withCoproductInstance[Inst]( - inline f: Inst => To + transparent inline def withCoproductInstance[Subtype]( + inline f: Subtype => To ): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = ${ PartialTransformerIntoMacros.withCoproductInstanceImpl('this, 'f) } /** Use `f` to calculate the (missing) coproduct instance partial result when mapping one coproduct into another. * - * By default if mapping one coproduct in `From` into another coproduct in `To` derivation - * expects that coproducts to have matching names of its components, and for every component - * in `To` field's type there is matching component in `From` type. If some component is missing - * it fails compilation unless provided replacement with this operation. + * By default if mapping one coproduct in `From` into another coproduct in `To` derivation expects that coproducts + * to have matching names of its components, and for every component in `To` field's type there is matching component + * in `From` type. If some component is missing it fails compilation unless provided replacement with this operation. * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.PartialTransformerInto]] * * @since 0.7.0 */ - transparent inline def withCoproductInstancePartial[Inst]( - inline f: Inst => partial.Result[To] + transparent inline def withCoproductInstancePartial[Subtype]( + inline f: Subtype => partial.Result[To] ): PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags] = ${ PartialTransformerIntoMacros.withCoproductInstancePartialImpl('this, 'f) } @@ -203,9 +204,8 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags /** Apply configured partial transformation in-place. * - * It runs macro that tries to derive instance of `PartialTransformer[From, To]` - * and immediately apply it to captured `source` value. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `PartialTransformer[From, To]` and immediately apply it to captured + * `source` value. When transformation can't be derived, it results with compilation error. * * @return partial transformation result of type `partial.Result[To]` * @@ -215,14 +215,17 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags tc: TransformerConfiguration[ImplicitScopeFlags] ): partial.Result[To] = ${ - PartialTransformerIntoMacros.transform[From, To, Cfg, Flags, ImplicitScopeFlags]('source, 'td, failFast = false) + PartialTransformerIntoMacros.transform[From, To, Overrides, Flags, ImplicitScopeFlags]( + 'source, + 'td, + failFast = false + ) } /** Apply configured partial transformation in-place in a short-circuit (fail fast) mode. * - * It runs macro that tries to derive instance of `PartialTransformer[From, To]` - * and immediately apply it to captured `source` value. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `PartialTransformer[From, To]` and immediately apply it to captured + * `source` value. When transformation can't be derived, it results with compilation error. * * @return partial transformation result of type `partial.Result[To]` * @@ -231,7 +234,13 @@ final class PartialTransformerInto[From, To, Cfg <: TransformerOverrides, Flags inline def transformFailFast[ImplicitScopeFlags <: TransformerFlags](using tc: TransformerConfiguration[ImplicitScopeFlags] ): partial.Result[To] = - ${ PartialTransformerIntoMacros.transform[From, To, Cfg, Flags, ImplicitScopeFlags]('source, 'td, failFast = true) } + ${ + PartialTransformerIntoMacros.transform[From, To, Overrides, Flags, ImplicitScopeFlags]( + 'source, + 'td, + failFast = true + ) + } private[chimney] def addOverride(overrideData: Any): this.type = new PartialTransformerInto(source, td.addOverride(overrideData)).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherDefinition.scala b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherDefinition.scala index 31a2c45f8..1faaa1b60 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherDefinition.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherDefinition.scala @@ -7,20 +7,20 @@ import io.scalaland.chimney.internal.runtime.{PatcherFlags, PatcherOverrides} /** Allows customization of [[io.scalaland.chimney.Patcher]] derivation. * - * @tparam A type of object to apply patch to - * @tparam Patch type of patch object - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam A type of object to apply patch to + * @tparam Patch type of patch object + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * * @since 0.8.0 */ -final class PatcherDefinition[A, Patch, Cfg <: PatcherOverrides, Flags <: PatcherFlags] - extends PatcherFlagsDsl[[Flags1 <: PatcherFlags] =>> PatcherDefinition[A, Patch, Cfg, Flags1], Flags] { +final class PatcherDefinition[A, Patch, Overrides <: PatcherOverrides, Flags <: PatcherFlags] + extends PatcherFlagsDsl[[Flags1 <: PatcherFlags] =>> PatcherDefinition[A, Patch, Overrides, Flags1], Flags] { /** Build Patcher using current configuration. * - * It runs macro that tries to derive instance of `Patcher[A, Patch]`. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `Patcher[A, Patch]`. When transformation can't be derived, it + * results with compilation error. * * @return [[io.scalaland.chimney.Patcher]] type class instance * @@ -29,5 +29,5 @@ final class PatcherDefinition[A, Patch, Cfg <: PatcherOverrides, Flags <: Patche inline def buildPatcher[ImplicitScopeFlags <: PatcherFlags](using tc: PatcherConfiguration[ImplicitScopeFlags] ): Patcher[A, Patch] = - ${ PatcherDefinitionMacros.buildPatcher[A, Patch, Cfg, Flags, ImplicitScopeFlags] } + ${ PatcherDefinitionMacros.buildPatcher[A, Patch, Overrides, Flags, ImplicitScopeFlags] } } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherUsing.scala b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherUsing.scala index 305f42aea..a7e385bc0 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherUsing.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/PatcherUsing.scala @@ -4,22 +4,23 @@ import io.scalaland.chimney.internal.* import io.scalaland.chimney.internal.compiletime.derivation.patcher.PatcherMacros import io.scalaland.chimney.internal.runtime.{PatcherFlags, PatcherOverrides} -/** Provides operations to customize [[io.scalaland.chimney.Patcher]] logic for specific - * object value and patch value. +/** Provides operations to customize [[io.scalaland.chimney.Patcher]] logic for specific object value and patch value. * - * @tparam A type of object to apply patch to - * @tparam Patch type of patch object - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam A type of object to apply patch to + * @tparam Patch type of patch object + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * @param obj object to patch * @param objPatch patch object * * @since 0.4.0 */ -final class PatcherUsing[A, Patch, Cfg <: PatcherOverrides, Flags <: PatcherFlags](val obj: A, val objPatch: Patch) - extends PatcherFlagsDsl[[Flags1 <: PatcherFlags] =>> PatcherUsing[A, Patch, Cfg, Flags1], Flags] { +final class PatcherUsing[A, Patch, Overrides <: PatcherOverrides, Flags <: PatcherFlags]( + val obj: A, + val objPatch: Patch +) extends PatcherFlagsDsl[[Flags1 <: PatcherFlags] =>> PatcherUsing[A, Patch, Overrides, Flags1], Flags] { - /** Applies configured patching in-place + /** Applies configured patching in-place. * * @return patched value * @@ -27,5 +28,7 @@ final class PatcherUsing[A, Patch, Cfg <: PatcherOverrides, Flags <: PatcherFlag */ inline def patch[ImplicitScopeFlags <: PatcherFlags](using tc: PatcherConfiguration[ImplicitScopeFlags] - ): A = ${ PatcherMacros.derivePatcherResultWithConfig[A, Patch, Cfg, Flags, ImplicitScopeFlags]('obj, 'objPatch) } + ): A = ${ + PatcherMacros.derivePatcherResultWithConfig[A, Patch, Overrides, Flags, ImplicitScopeFlags]('obj, 'objPatch) + } } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinition.scala b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinition.scala index 4fd89b560..c9c1e2880 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinition.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinition.scala @@ -9,28 +9,32 @@ import scala.quoted.* /** Allows customization of [[io.scalaland.chimney.Transformer]] derivation. * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * * @since 0.4.0 */ -final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class TransformerDefinition[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val runtimeData: TransformerDefinitionCommons.RuntimeDataStore -) extends TransformerFlagsDsl[[Flags1 <: TransformerFlags] =>> TransformerDefinition[From, To, Cfg, Flags1], Flags] - with TransformerDefinitionCommons[[Cfg1 <: TransformerOverrides] =>> TransformerDefinition[From, To, Cfg1, Flags]] +) extends TransformerFlagsDsl[ + [Flags1 <: TransformerFlags] =>> TransformerDefinition[From, To, Overrides, Flags1], + Flags + ] + with TransformerDefinitionCommons[ + [Overrides1 <: TransformerOverrides] =>> TransformerDefinition[From, To, Overrides1, Flags] + ] with WithRuntimeDataStore { /** Lifts current transformer definition as `PartialTransformer` definition * - * It keeps all the configuration, provided missing values, renames, - * coproduct instances etc. + * It keeps all the configuration, provided missing values, renames, coproduct instances etc. * * @return [[io.scalaland.chimney.dsl.PartialTransformerDefinition]] */ - def partial: PartialTransformerDefinition[From, To, Cfg, Flags] = - new PartialTransformerDefinition[From, To, Cfg, Flags](runtimeData) + def partial: PartialTransformerDefinition[From, To, Overrides, Flags] = + new PartialTransformerDefinition[From, To, Overrides, Flags](runtimeData) /** Use provided value `value` for field picked using `selector`. * @@ -94,21 +98,20 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another. * - * By default if mapping one coproduct in `From` into another coproduct in `To` derivation - * expects that coproducts to have matching names of its components, and for every component - * in `To` field's type there is matching component in `From` type. If some component is missing - * it fails compilation unless provided replacement with this operation. + * By default if mapping one coproduct in `From` into another coproduct in `To` derivation expects that coproducts + * to have matching names of its components, and for every component in `To` field's type there is matching component + * in `From` type. If some component is missing it fails compilation unless provided replacement with this operation. * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance + * @tparam Subtypetype of coproduct instance * @param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.TransformerDefinition]] * * @since 0.4.0 */ - transparent inline def withCoproductInstance[Inst]( - inline f: Inst => To + transparent inline def withCoproductInstance[Subtype]( + inline f: Subtype => To ): TransformerDefinition[From, To, ? <: TransformerOverrides, Flags] = ${ TransformerDefinitionMacros.withCoproductInstance('this, 'f) } @@ -133,8 +136,8 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < /** Build Transformer using current configuration. * - * It runs macro that tries to derive instance of `Transformer[From, To]`. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `Transformer[From, To]`. When transformation can't be derived, it + * results with compilation error. * * @return [[io.scalaland.chimney.Transformer]] type class instance * @@ -143,7 +146,7 @@ final class TransformerDefinition[From, To, Cfg <: TransformerOverrides, Flags < inline def buildTransformer[ImplicitScopeFlags <: TransformerFlags](using tc: TransformerConfiguration[ImplicitScopeFlags] ): Transformer[From, To] = - ${ TransformerDefinitionMacros.buildTransformer[From, To, Cfg, Flags, ImplicitScopeFlags]('this) } + ${ TransformerDefinitionMacros.buildTransformer[From, To, Overrides, Flags, ImplicitScopeFlags]('this) } private[chimney] def addOverride(overrideData: Any): this.type = new TransformerDefinition(overrideData +: runtimeData).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala index 344749600..d991ff24f 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerDefinitionCommons.scala @@ -13,7 +13,7 @@ object TransformerDefinitionCommons { // @static final def emptyRuntimeDataStore: RuntimeDataStore = Vector.empty[Any] } -private[chimney] trait TransformerDefinitionCommons[UpdateCfg[_ <: TransformerOverrides]] { +private[chimney] trait TransformerDefinitionCommons[UpdateTail[_ <: TransformerOverrides]] { import TransformerDefinitionCommons.* diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerInto.scala b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerInto.scala index 5aa127af0..0cea3df38 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerInto.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/dsl/TransformerInto.scala @@ -5,33 +5,32 @@ import io.scalaland.chimney.internal.compiletime.derivation.transformer.Transfor import io.scalaland.chimney.internal.compiletime.dsl.TransformerIntoMacros import io.scalaland.chimney.internal.runtime.{IsFunction, TransformerFlags, TransformerOverrides, WithRuntimeDataStore} -/** Provides DSL for configuring [[io.scalaland.chimney.Transformer]]'s - * generation and using the result to transform value at the same time +/** Provides DSL for configuring [[io.scalaland.chimney.Transformer]]'s generation and using the result to transform + * value at the same time * - * @tparam From type of input value - * @tparam To type of output value - * @tparam Cfg type-level encoded config - * @tparam Flags type-level encoded flags + * @tparam From type of input value + * @tparam To type of output value + * @tparam Overrides type-level encoded config + * @tparam Flags type-level encoded flags * @param source object to transform * @param td transformer definition * * @since 0.1.0 */ -final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: TransformerFlags]( +final class TransformerInto[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags]( val source: From, - val td: TransformerDefinition[From, To, Cfg, Flags] -) extends TransformerFlagsDsl[[Flags1 <: TransformerFlags] =>> TransformerInto[From, To, Cfg, Flags1], Flags] + val td: TransformerDefinition[From, To, Overrides, Flags] +) extends TransformerFlagsDsl[[Flags1 <: TransformerFlags] =>> TransformerInto[From, To, Overrides, Flags1], Flags] with WithRuntimeDataStore { /** Lifts current transformation as partial transformation. * - * It keeps all the configuration, provided missing values, renames, - * coproduct instances etc. + * It keeps all the configuration, provided missing values, renames, coproduct instances etc. * * @return [[io.scalaland.chimney.dsl.PartialTransformerInto]] */ - def partial: PartialTransformerInto[From, To, Cfg, Flags] = - new PartialTransformerInto[From, To, Cfg, Flags](source, td.partial) + def partial: PartialTransformerInto[From, To, Overrides, Flags] = + new PartialTransformerInto[From, To, Overrides, Flags](source, td.partial) /** Use `value` provided here for field picked using `selector`. * @@ -91,20 +90,19 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran /** Use `f` to calculate the (missing) coproduct instance when mapping one coproduct into another * - * By default if mapping one coproduct in `From` into another coproduct in `To` derivation - * expects that coproducts will have matching names of its components, and for every component - * in `To` field's type there is matching component in `From` type. If some component is missing - * it will fail. + * By default if mapping one coproduct in `From` into another coproduct in `To` derivation expects that coproducts + * will have matching names of its components, and for every component in `To` field's type there is matching + * component in `From` type. If some component is missing it will fail. * * @see [[https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value]] for more details * - * @tparam Inst type of coproduct instance@param f function to calculate values of components that cannot be mapped automatically + * @tparam Subtypetype of coproduct instance@param f function to calculate values of components that cannot be mapped automatically * @return [[io.scalaland.chimney.dsl.TransformerInto]] * * @since 0.1.2 */ - transparent inline def withCoproductInstance[Inst]( - inline f: Inst => To + transparent inline def withCoproductInstance[Subtype]( + inline f: Subtype => To ): TransformerInto[From, To, ? <: TransformerOverrides, Flags] = ${ TransformerIntoMacros.withCoproductInstanceImpl('this, 'f) } @@ -129,9 +127,8 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran /** Apply configured transformation in-place. * - * It runs macro that tries to derive instance of `Transformer[From, To]` - * and immediately apply it to captured `source` value. - * When transformation can't be derived, it results with compilation error. + * It runs macro that tries to derive instance of `Transformer[From, To]` and immediately apply it to captured + * `source` value. When transformation can't be derived, it results with compilation error. * * @return transformed value of type `To` * @@ -140,7 +137,7 @@ final class TransformerInto[From, To, Cfg <: TransformerOverrides, Flags <: Tran inline def transform[ImplicitScopeFlags <: TransformerFlags](using tc: TransformerConfiguration[ImplicitScopeFlags] ): To = - ${ TransformerIntoMacros.transform[From, To, Cfg, Flags, ImplicitScopeFlags]('source, 'td) } + ${ TransformerIntoMacros.transform[From, To, Overrides, Flags, ImplicitScopeFlags]('source, 'td) } private[chimney] def addOverride(overrideData: Any): this.type = new TransformerInto(source, td.addOverride(overrideData)).asInstanceOf[this.type] diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala index af91a0737..f54bfd32c 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/ChimneyTypesPlatform.scala @@ -73,36 +73,36 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi object TransformerOverrides extends TransformerOverridesModule { val Empty: Type[runtime.TransformerOverrides.Empty] = quoted.Type.of[runtime.TransformerOverrides.Empty] object Const extends ConstModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.Const[ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.Const[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.Const[ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.Const[ToPath, Tail]] def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match case '[runtime.TransformerOverrides.Const[toPath, cfg]] => Some((Type[toPath].as_?<[runtime.Path], Type[cfg].as_?<[runtime.TransformerOverrides])) case _ => scala.None } object ConstPartial extends ConstPartialModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.ConstPartial[ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.ConstPartial[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.ConstPartial[ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.ConstPartial[ToPath, Tail]] def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match case '[runtime.TransformerOverrides.ConstPartial[toPath, cfg]] => Some((Type[toPath].as_>?<[Nothing, runtime.Path], Type[cfg].as_>?<[Nothing, runtime.TransformerOverrides])) case _ => scala.None } object Computed extends ComputedModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.Computed[ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.Computed[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.Computed[ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.Computed[ToPath, Tail]] def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match case '[runtime.TransformerOverrides.Computed[toPath, cfg]] => Some((Type[toPath].as_?<[runtime.Path], Type[cfg].as_?<[runtime.TransformerOverrides])) case _ => scala.None } object ComputedPartial extends ComputedPartialModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.ComputedPartial[ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.ComputedPartial[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.ComputedPartial[ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.ComputedPartial[ToPath, Tail]] def unapply[A](tpe: Type[A]): Option[(Nothing >?< runtime.Path, Nothing >?< runtime.TransformerOverrides)] = tpe match case '[runtime.TransformerOverrides.ComputedPartial[toPath, cfg]] => @@ -110,18 +110,18 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi case _ => scala.None } object CaseComputed extends CaseComputedModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.CaseComputed[ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.CaseComputed[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.CaseComputed[ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.CaseComputed[ToPath, Tail]] def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match case '[runtime.TransformerOverrides.CaseComputed[toPath, cfg]] => Some((Type[toPath].as_?<[runtime.Path], Type[cfg].as_?<[runtime.TransformerOverrides])) case _ => scala.None } object CaseComputedPartial extends CaseComputedPartialModule { - def apply[ToPath <: runtime.Path: Type, Cfg <: runtime.TransformerOverrides: Type] - : Type[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Cfg]] + def apply[ToPath <: runtime.Path: Type, Tail <: runtime.TransformerOverrides: Type] + : Type[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.CaseComputedPartial[ToPath, Tail]] def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match case '[runtime.TransformerOverrides.CaseComputedPartial[toPath, cfg]] => Some((Type[toPath].as_?<[runtime.Path], Type[cfg].as_?<[runtime.TransformerOverrides])) @@ -131,9 +131,9 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi def apply[ Args <: runtime.ArgumentLists: Type, ToPath <: runtime.Path: Type, - Cfg <: runtime.TransformerOverrides: Type - ]: Type[runtime.TransformerOverrides.Constructor[Args, ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.Constructor[Args, ToPath, Cfg]] + Tail <: runtime.TransformerOverrides: Type + ]: Type[runtime.TransformerOverrides.Constructor[Args, ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.Constructor[Args, ToPath, Tail]] def unapply[A]( tpe: Type[A] ): Option[(?<[runtime.ArgumentLists], ?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match @@ -151,9 +151,9 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi def apply[ Args <: runtime.ArgumentLists: Type, ToPath <: runtime.Path: Type, - Cfg <: runtime.TransformerOverrides: Type - ]: Type[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Cfg]] + Tail <: runtime.TransformerOverrides: Type + ]: Type[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.ConstructorPartial[Args, ToPath, Tail]] def unapply[A]( tpe: Type[A] ): Option[(?<[runtime.ArgumentLists], ?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match @@ -171,9 +171,9 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi def apply[ FromPath <: runtime.Path: Type, ToPath <: runtime.Path: Type, - Cfg <: runtime.TransformerOverrides: Type - ]: Type[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Cfg]] = - quoted.Type.of[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Cfg]] + Tail <: runtime.TransformerOverrides: Type + ]: Type[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Tail]] = + quoted.Type.of[runtime.TransformerOverrides.RenamedFrom[FromPath, ToPath, Tail]] def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ?<[runtime.Path], ?<[runtime.TransformerOverrides])] = tpe match case '[runtime.TransformerOverrides.RenamedFrom[fromPath, toPath, cfg]] => @@ -304,19 +304,19 @@ private[compiletime] trait ChimneyTypesPlatform extends ChimneyTypes { this: Chi object Path extends PathModule { val Root: Type[runtime.Path.Root] = quoted.Type.of[runtime.Path.Root] object Select extends SelectModule { - def apply[Name <: String: Type, Instance <: runtime.Path: Type]: Type[runtime.Path.Select[Name, Instance]] = - quoted.Type.of[runtime.Path.Select[Name, Instance]] - def unapply[A](tpe: Type[A]): Option[(?<[String], ?<[runtime.Path])] = tpe match - case '[runtime.Path.Select[name, instance]] => - Some((Type[name].as_?<[String], Type[instance].as_?<[runtime.Path])) + def apply[Init <: runtime.Path: Type, FieldName <: String: Type]: Type[runtime.Path.Select[Init, FieldName]] = + quoted.Type.of[runtime.Path.Select[Init, FieldName]] + def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ?<[String])] = tpe match + case '[runtime.Path.Select[init, fieldName]] => + Some((Type[init].as_?<[runtime.Path], Type[fieldName].as_?<[String])) case _ => scala.None } object Match extends MatchModule { - def apply[Subtype: Type, Instance <: runtime.Path: Type]: Type[runtime.Path.Match[Subtype, Instance]] = - quoted.Type.of[runtime.Path.Match[Subtype, Instance]] - def unapply[A](tpe: Type[A]): Option[(??, ?<[runtime.Path])] = tpe match - case '[runtime.Path.Match[subtype, instance]] => - Some((Type[subtype].as_??, Type[instance].as_?<[runtime.Path])) + def apply[Init <: runtime.Path: Type, Subtype: Type]: Type[runtime.Path.Match[Init, Subtype]] = + quoted.Type.of[runtime.Path.Match[Init, Subtype]] + def unapply[A](tpe: Type[A]): Option[(?<[runtime.Path], ??)] = tpe match + case '[runtime.Path.Match[init, subtype]] => + Some((Type[init].as_?<[runtime.Path], Type[subtype].as_??)) case _ => scala.None } } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala index de9260038..3120b6005 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/patcher/PatcherMacros.scala @@ -12,11 +12,11 @@ final class PatcherMacros(q: Quotes) extends DerivationPlatform(q) with Gateway def derivePatcherWithConfig[ A: Type, Patch: Type, - Cfg <: runtime.PatcherOverrides: Type, + Overrides <: runtime.PatcherOverrides: Type, Flags <: runtime.PatcherFlags: Type, ImplicitScopeFlags <: runtime.PatcherFlags: Type ]: Expr[Patcher[A, Patch]] = - derivePatcher[A, Patch, Cfg, Flags, ImplicitScopeFlags] + derivePatcher[A, Patch, Overrides, Flags, ImplicitScopeFlags] def derivePatcherWithDefaults[ A: Type, @@ -53,11 +53,11 @@ object PatcherMacros { final def derivePatcherWithConfig[ A: Type, Patch: Type, - Cfg <: runtime.PatcherOverrides: Type, + Overrides <: runtime.PatcherOverrides: Type, Flags <: runtime.PatcherFlags: Type, ImplicitScopeFlags <: runtime.PatcherFlags: Type ](using q: Quotes): Expr[Patcher[A, Patch]] = - new PatcherMacros(q).derivePatcherWithConfig[A, Patch, Cfg, Flags, ImplicitScopeFlags] + new PatcherMacros(q).derivePatcherWithConfig[A, Patch, Overrides, Flags, ImplicitScopeFlags] final def derivePatcherWithDefaults[A: Type, Patch: Type](using q: Quotes): Expr[Patcher[A, Patch]] = new PatcherMacros(q).derivePatcherWithDefaults[A, Patch] @@ -65,12 +65,12 @@ object PatcherMacros { final def derivePatcherResultWithConfig[ A: Type, Patch: Type, - Cfg <: runtime.PatcherOverrides: Type, + Overrides <: runtime.PatcherOverrides: Type, Flags <: runtime.PatcherFlags: Type, ImplicitScopeFlags <: runtime.PatcherFlags: Type ]( obj: Expr[A], patch: Expr[Patch] )(using q: Quotes): Expr[A] = - new PatcherMacros(q).derivePatcherResult[A, Patch, Cfg, Flags, ImplicitScopeFlags](obj, patch) + new PatcherMacros(q).derivePatcherResult[A, Patch, Overrides, Flags, ImplicitScopeFlags](obj, patch) } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala index 75fd7bb29..9ef177db0 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/derivation/transformer/TransformerMacros.scala @@ -15,13 +15,13 @@ final class TransformerMacros(q: Quotes) extends DerivationPlatform(q) with Gate def deriveTotalTransformerWithConfig[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Overrides <: runtime.TransformerOverrides: Type, Flags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( - td: Expr[TransformerDefinition[From, To, Cfg, Flags]] + td: Expr[TransformerDefinition[From, To, Overrides, Flags]] ): Expr[Transformer[From, To]] = - deriveTotalTransformer[From, To, Cfg, Flags, ImplicitScopeFlags](runtimeDataStore = '{ ${ td }.runtimeData }) + deriveTotalTransformer[From, To, Overrides, Flags, ImplicitScopeFlags](runtimeDataStore = '{ ${ td }.runtimeData }) def deriveTotalTransformerWithDefaults[ From: Type, @@ -56,13 +56,15 @@ final class TransformerMacros(q: Quotes) extends DerivationPlatform(q) with Gate def derivePartialTransformerWithConfig[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Overrides <: runtime.TransformerOverrides: Type, Flags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]] + td: Expr[PartialTransformerDefinition[From, To, Overrides, Flags]] ): Expr[PartialTransformer[From, To]] = - derivePartialTransformer[From, To, Cfg, Flags, ImplicitScopeFlags](runtimeDataStore = '{ ${ td }.runtimeData }) + derivePartialTransformer[From, To, Overrides, Flags, ImplicitScopeFlags](runtimeDataStore = '{ + ${ td }.runtimeData + }) private def resolveImplicitScopeConfigAndMuteUnusedWarnings[A: Type]( useImplicitScopeFlags: ?<[runtime.TransformerFlags] => Expr[A] @@ -96,22 +98,22 @@ object TransformerMacros { final def deriveTotalTransformerWithConfig[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Overrides <: runtime.TransformerOverrides: Type, Flags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( - td: Expr[TransformerDefinition[From, To, Cfg, Flags]] + td: Expr[TransformerDefinition[From, To, Overrides, Flags]] )(using quotes: Quotes): Expr[Transformer[From, To]] = - new TransformerMacros(quotes).deriveTotalTransformerWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags](td) + new TransformerMacros(quotes).deriveTotalTransformerWithConfig[From, To, Overrides, Flags, ImplicitScopeFlags](td) final def deriveTotalTransformerResultWithConfig[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Overrides <: runtime.TransformerOverrides: Type, Flags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type - ](source: Expr[From], td: Expr[TransformerDefinition[From, To, Cfg, Flags]])(using quotes: Quotes): Expr[To] = - new TransformerMacros(quotes).deriveTotalTransformationResult[From, To, Cfg, Flags, ImplicitScopeFlags]( + ](source: Expr[From], td: Expr[TransformerDefinition[From, To, Overrides, Flags]])(using quotes: Quotes): Expr[To] = + new TransformerMacros(quotes).deriveTotalTransformationResult[From, To, Overrides, Flags, ImplicitScopeFlags]( source, '{ ${ td }.runtimeData } ) @@ -125,24 +127,24 @@ object TransformerMacros { final def derivePartialTransformerWithConfig[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Overrides <: runtime.TransformerOverrides: Type, Flags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]] + td: Expr[PartialTransformerDefinition[From, To, Overrides, Flags]] )(using quotes: Quotes): Expr[PartialTransformer[From, To]] = - new TransformerMacros(quotes).derivePartialTransformerWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags](td) + new TransformerMacros(quotes).derivePartialTransformerWithConfig[From, To, Overrides, Flags, ImplicitScopeFlags](td) final def derivePartialTransformerResultWithConfig[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Overrides <: runtime.TransformerOverrides: Type, Flags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type - ](source: Expr[From], td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], failFast: Boolean)(using + ](source: Expr[From], td: Expr[PartialTransformerDefinition[From, To, Overrides, Flags]], failFast: Boolean)(using quotes: Quotes ): Expr[partial.Result[To]] = - new TransformerMacros(quotes).derivePartialTransformationResult[From, To, Cfg, Flags, ImplicitScopeFlags]( + new TransformerMacros(quotes).derivePartialTransformationResult[From, To, Overrides, Flags, ImplicitScopeFlags]( source, Expr(failFast), '{ ${ td }.runtimeData } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala index 54ee3fb82..a9921c5e8 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerDefinitionMacros.scala @@ -21,12 +21,12 @@ object PartialTransformerDefinitionMacros { def withFieldConstImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], selector: Expr[To => T], value: Expr[U] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -36,19 +36,19 @@ object PartialTransformerDefinitionMacros { '{ WithRuntimeDataStore .update($td, $value) - .asInstanceOf[PartialTransformerDefinition[From, To, Const[toPath, Cfg], Flags]] + .asInstanceOf[PartialTransformerDefinition[From, To, Const[toPath, Tail], Flags]] } }(selector) def withFieldConstPartialImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], selector: Expr[To => T], value: Expr[partial.Result[U]] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -61,7 +61,7 @@ object PartialTransformerDefinitionMacros { .asInstanceOf[PartialTransformerDefinition[ From, To, - ConstPartial[toPath, Cfg], + ConstPartial[toPath, Tail], Flags ]] } @@ -70,12 +70,12 @@ object PartialTransformerDefinitionMacros { def withFieldComputedImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], selector: Expr[To => T], f: Expr[From => U] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -85,19 +85,19 @@ object PartialTransformerDefinitionMacros { '{ WithRuntimeDataStore .update($td, $f) - .asInstanceOf[PartialTransformerDefinition[From, To, Computed[toPath, Cfg], Flags]] + .asInstanceOf[PartialTransformerDefinition[From, To, Computed[toPath, Tail], Flags]] } }(selector) def withFieldComputedPartialImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], selector: Expr[To => T], f: Expr[From => partial.Result[U]] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -110,7 +110,7 @@ object PartialTransformerDefinitionMacros { .asInstanceOf[PartialTransformerDefinition[ From, To, - ComputedPartial[toPath, Cfg], + ComputedPartial[toPath, Tail], Flags ]] } @@ -119,12 +119,12 @@ object PartialTransformerDefinitionMacros { def withFieldRenamed[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], selectorFrom: Expr[From => T], selectorTo: Expr[To => U] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -134,7 +134,7 @@ object PartialTransformerDefinitionMacros { (_: Type[toPath]) ?=> '{ $td.asInstanceOf[ - PartialTransformerDefinition[From, To, RenamedFrom[fromPath, toPath, Cfg], Flags] + PartialTransformerDefinition[From, To, RenamedFrom[fromPath, toPath, Tail], Flags] ] } }(selectorFrom, selectorTo) @@ -142,28 +142,28 @@ object PartialTransformerDefinitionMacros { def withCoproductInstance[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, - Inst: Type + Subtype: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], - f: Expr[Inst => To] + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], + f: Expr[Subtype => To] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = '{ WithRuntimeDataStore .update($td, $f) - .asInstanceOf[PartialTransformerDefinition[From, To, CaseComputed[Path.Match[Inst, Path.Root], Cfg], Flags]] + .asInstanceOf[PartialTransformerDefinition[From, To, CaseComputed[Path.Match[Path.Root, Subtype], Tail], Flags]] } def withCoproductInstancePartial[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, - Inst: Type + Subtype: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], - f: Expr[Inst => partial.Result[To]] + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], + f: Expr[Subtype => partial.Result[To]] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = '{ WithRuntimeDataStore @@ -171,7 +171,7 @@ object PartialTransformerDefinitionMacros { .asInstanceOf[PartialTransformerDefinition[ From, To, - CaseComputedPartial[Path.Match[Inst, Path.Root], Cfg], + CaseComputedPartial[Path.Match[Path.Root, Subtype], Tail], Flags ]] } @@ -179,11 +179,11 @@ object PartialTransformerDefinitionMacros { def withConstructorImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, Ctor: Type ]( - ti: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], f: Expr[Ctor] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = DslMacroUtils().applyConstructorType { @@ -192,18 +192,18 @@ object PartialTransformerDefinitionMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerDefinition[From, To, Constructor[args, Path.Root, Cfg], Flags]] + .asInstanceOf[PartialTransformerDefinition[From, To, Constructor[args, Path.Root, Tail], Flags]] } }(f) def withConstructorPartialImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, Ctor: Type ]( - ti: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], f: Expr[Ctor] )(using Quotes): Expr[PartialTransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = DslMacroUtils().applyConstructorType { @@ -212,18 +212,18 @@ object PartialTransformerDefinitionMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerDefinition[From, To, ConstructorPartial[args, Path.Root, Cfg], Flags]] + .asInstanceOf[PartialTransformerDefinition[From, To, ConstructorPartial[args, Path.Root, Tail], Flags]] } }(f) def buildTransformer[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, ImplicitScopeFlags <: TransformerFlags: Type ]( - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]] + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]] )(using Quotes): Expr[PartialTransformer[From, To]] = - TransformerMacros.derivePartialTransformerWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags](td) + TransformerMacros.derivePartialTransformerWithConfig[From, To, Tail, Flags, ImplicitScopeFlags](td) } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala index 2ed45a18e..139d29fc3 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PartialTransformerIntoMacros.scala @@ -21,12 +21,12 @@ object PartialTransformerIntoMacros { def withFieldConstImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], selector: Expr[To => T], value: Expr[U] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -36,19 +36,19 @@ object PartialTransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $value) - .asInstanceOf[PartialTransformerInto[From, To, Const[toPath, Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[From, To, Const[toPath, Tail], Flags]] } }(selector) def withFieldConstPartialImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], selector: Expr[To => T], value: Expr[partial.Result[U]] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -58,19 +58,19 @@ object PartialTransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $value) - .asInstanceOf[PartialTransformerInto[From, To, ConstPartial[toPath, Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[From, To, ConstPartial[toPath, Tail], Flags]] } }(selector) def withFieldComputedImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], selector: Expr[To => T], f: Expr[From => U] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -80,19 +80,19 @@ object PartialTransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerInto[From, To, Computed[toPath, Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[From, To, Computed[toPath, Tail], Flags]] } }(selector) def withFieldComputedPartialImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], selector: Expr[To => T], f: Expr[From => partial.Result[U]] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -102,19 +102,19 @@ object PartialTransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerInto[From, To, ComputedPartial[toPath, Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[From, To, ComputedPartial[toPath, Tail], Flags]] } }(selector) def withFieldRenamedImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], selectorFrom: Expr[From => T], selectorTo: Expr[To => U] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -124,7 +124,7 @@ object PartialTransformerIntoMacros { (_: Type[toPath]) ?=> '{ $ti.asInstanceOf[ - PartialTransformerInto[From, To, RenamedFrom[fromPath, toPath, Cfg], Flags] + PartialTransformerInto[From, To, RenamedFrom[fromPath, toPath, Tail], Flags] ] } }(selectorFrom, selectorTo) @@ -132,43 +132,48 @@ object PartialTransformerIntoMacros { def withCoproductInstanceImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, - Inst: Type + Subtype: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], - f: Expr[Inst => To] + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], + f: Expr[Subtype => To] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerInto[From, To, CaseComputed[Path.Match[Inst, Path.Root], Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[From, To, CaseComputed[Path.Match[Path.Root, Subtype], Tail], Flags]] } def withCoproductInstancePartialImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, - Inst: Type + Subtype: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], - f: Expr[Inst => partial.Result[To]] + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], + f: Expr[Subtype => partial.Result[To]] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerInto[From, To, CaseComputedPartial[Path.Match[Inst, Path.Root], Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[ + From, + To, + CaseComputedPartial[Path.Match[Path.Root, Subtype], Tail], + Flags + ]] } def withConstructorImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, Ctor: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], f: Expr[Ctor] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = DslMacroUtils().applyConstructorType { @@ -177,18 +182,18 @@ object PartialTransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerInto[From, To, Constructor[args, Path.Root, Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[From, To, Constructor[args, Path.Root, Tail], Flags]] } }(f) def withConstructorPartialImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, Ctor: Type ]( - ti: Expr[PartialTransformerInto[From, To, Cfg, Flags]], + ti: Expr[PartialTransformerInto[From, To, Tail, Flags]], f: Expr[Ctor] )(using Quotes): Expr[PartialTransformerInto[From, To, ? <: TransformerOverrides, Flags]] = DslMacroUtils().applyConstructorType { @@ -197,22 +202,22 @@ object PartialTransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[PartialTransformerInto[From, To, ConstructorPartial[args, Path.Root, Cfg], Flags]] + .asInstanceOf[PartialTransformerInto[From, To, ConstructorPartial[args, Path.Root, Tail], Flags]] } }(f) def transform[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, ImplicitScopeFlags <: TransformerFlags: Type ]( source: Expr[From], - td: Expr[PartialTransformerDefinition[From, To, Cfg, Flags]], + td: Expr[PartialTransformerDefinition[From, To, Tail, Flags]], failFast: Boolean )(using Quotes): Expr[partial.Result[To]] = - TransformerMacros.derivePartialTransformerResultWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags]( + TransformerMacros.derivePartialTransformerResultWithConfig[From, To, Tail, Flags, ImplicitScopeFlags]( source, td, failFast diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PatcherDefinitionMacros.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PatcherDefinitionMacros.scala index ca44e114e..f3d68eaf3 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PatcherDefinitionMacros.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/PatcherDefinitionMacros.scala @@ -12,9 +12,9 @@ object PatcherDefinitionMacros { def buildPatcher[ A: Type, Patch: Type, - Cfg <: PatcherOverrides: Type, + Tail <: PatcherOverrides: Type, Flags <: PatcherFlags: Type, ImplicitScopeFlags <: PatcherFlags: Type ](using Quotes): Expr[Patcher[A, Patch]] = - PatcherMacros.derivePatcherWithConfig[A, Patch, Cfg, Flags, ImplicitScopeFlags] + PatcherMacros.derivePatcherWithConfig[A, Patch, Tail, Flags, ImplicitScopeFlags] } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala index 7af6a4d82..6b58ce7ec 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerDefinitionMacros.scala @@ -20,12 +20,12 @@ object TransformerDefinitionMacros { def withFieldConstImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[TransformerDefinition[From, To, Cfg, Flags]], + td: Expr[TransformerDefinition[From, To, Tail, Flags]], selector: Expr[To => T], value: Expr[U] )(using Quotes): Expr[TransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -35,19 +35,19 @@ object TransformerDefinitionMacros { '{ WithRuntimeDataStore .update($td, $value) - .asInstanceOf[TransformerDefinition[From, To, Const[toPath, Cfg], Flags]] + .asInstanceOf[TransformerDefinition[From, To, Const[toPath, Tail], Flags]] } }(selector) def withFieldComputedImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[TransformerDefinition[From, To, Cfg, Flags]], + td: Expr[TransformerDefinition[From, To, Tail, Flags]], selector: Expr[To => T], f: Expr[From => U] )(using Quotes): Expr[TransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -57,19 +57,19 @@ object TransformerDefinitionMacros { '{ WithRuntimeDataStore .update($td, $f) - .asInstanceOf[TransformerDefinition[From, To, Computed[toPath, Cfg], Flags]] + .asInstanceOf[TransformerDefinition[From, To, Computed[toPath, Tail], Flags]] } }(selector) def withFieldRenamed[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - td: Expr[TransformerDefinition[From, To, Cfg, Flags]], + td: Expr[TransformerDefinition[From, To, Tail, Flags]], selectorFrom: Expr[From => T], selectorTo: Expr[To => U] )(using Quotes): Expr[TransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = @@ -81,7 +81,7 @@ object TransformerDefinitionMacros { $td.asInstanceOf[TransformerDefinition[ From, To, - RenamedFrom[fromPath, toPath, Cfg], + RenamedFrom[fromPath, toPath, Tail], Flags ]] } @@ -90,27 +90,27 @@ object TransformerDefinitionMacros { def withCoproductInstance[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, - Inst: Type + Subtype: Type ]( - td: Expr[TransformerDefinition[From, To, Cfg, Flags]], - f: Expr[Inst => To] + td: Expr[TransformerDefinition[From, To, Tail, Flags]], + f: Expr[Subtype => To] )(using Quotes): Expr[TransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = '{ WithRuntimeDataStore .update($td, $f) - .asInstanceOf[TransformerDefinition[From, To, CaseComputed[Path.Match[Inst, Path.Root], Cfg], Flags]] + .asInstanceOf[TransformerDefinition[From, To, CaseComputed[Path.Match[Path.Root, Subtype], Tail], Flags]] } def withConstructorImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, Ctor: Type ]( - ti: Expr[TransformerDefinition[From, To, Cfg, Flags]], + ti: Expr[TransformerDefinition[From, To, Tail, Flags]], f: Expr[Ctor] )(using Quotes): Expr[TransformerDefinition[From, To, ? <: TransformerOverrides, Flags]] = DslMacroUtils().applyConstructorType { @@ -119,18 +119,18 @@ object TransformerDefinitionMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[TransformerDefinition[From, To, Constructor[args, Path.Root, Cfg], Flags]] + .asInstanceOf[TransformerDefinition[From, To, Constructor[args, Path.Root, Tail], Flags]] } }(f) def buildTransformer[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, ImplicitScopeFlags <: TransformerFlags: Type ]( - td: Expr[TransformerDefinition[From, To, Cfg, Flags]] + td: Expr[TransformerDefinition[From, To, Tail, Flags]] )(using Quotes): Expr[Transformer[From, To]] = - TransformerMacros.deriveTotalTransformerWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags](td) + TransformerMacros.deriveTotalTransformerWithConfig[From, To, Tail, Flags, ImplicitScopeFlags](td) } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala index bf6e6c67a..5b1ef4413 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/TransformerIntoMacros.scala @@ -21,12 +21,12 @@ object TransformerIntoMacros { def withFieldConstImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[TransformerInto[From, To, Cfg, Flags]], + ti: Expr[TransformerInto[From, To, Tail, Flags]], selector: Expr[To => T], value: Expr[U] )(using Quotes): Expr[TransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -36,19 +36,19 @@ object TransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $value) - .asInstanceOf[TransformerInto[From, To, Const[toPath, Cfg], Flags]] + .asInstanceOf[TransformerInto[From, To, Const[toPath, Tail], Flags]] } }(selector) def withFieldComputedImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[TransformerInto[From, To, Cfg, Flags]], + ti: Expr[TransformerInto[From, To, Tail, Flags]], selector: Expr[To => T], f: Expr[From => U] )(using Quotes): Expr[TransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -58,19 +58,19 @@ object TransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[TransformerInto[From, To, Computed[toPath, Cfg], Flags]] + .asInstanceOf[TransformerInto[From, To, Computed[toPath, Tail], Flags]] } }(selector) def withFieldRenamedImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, T: Type, U: Type ]( - ti: Expr[TransformerInto[From, To, Cfg, Flags]], + ti: Expr[TransformerInto[From, To, Tail, Flags]], selectorFrom: Expr[From => T], selectorTo: Expr[To => U] )(using Quotes): Expr[TransformerInto[From, To, ? <: TransformerOverrides, Flags]] = @@ -79,34 +79,34 @@ object TransformerIntoMacros { (_: Type[fromPath]) ?=> (_: Type[toPath]) ?=> '{ - $ti.asInstanceOf[TransformerInto[From, To, RenamedFrom[fromPath, toPath, Cfg], Flags]] + $ti.asInstanceOf[TransformerInto[From, To, RenamedFrom[fromPath, toPath, Tail], Flags]] } }(selectorFrom, selectorTo) def withCoproductInstanceImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, - Inst: Type + Subtype: Type ]( - ti: Expr[TransformerInto[From, To, Cfg, Flags]], - f: Expr[Inst => To] + ti: Expr[TransformerInto[From, To, Tail, Flags]], + f: Expr[Subtype => To] )(using Quotes): Expr[TransformerInto[From, To, ? <: TransformerOverrides, Flags]] = '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[TransformerInto[From, To, CaseComputed[Path.Match[Inst, Path.Root], Cfg], Flags]] + .asInstanceOf[TransformerInto[From, To, CaseComputed[Path.Match[Path.Root, Subtype], Tail], Flags]] } def withConstructorImpl[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, Ctor: Type ]( - ti: Expr[TransformerInto[From, To, Cfg, Flags]], + ti: Expr[TransformerInto[From, To, Tail, Flags]], f: Expr[Ctor] )(using Quotes): Expr[TransformerInto[From, To, ? <: TransformerOverrides, Flags]] = DslMacroUtils().applyConstructorType { @@ -115,19 +115,19 @@ object TransformerIntoMacros { '{ WithRuntimeDataStore .update($ti, $f) - .asInstanceOf[TransformerInto[From, To, Constructor[args, Path.Root, Cfg], Flags]] + .asInstanceOf[TransformerInto[From, To, Constructor[args, Path.Root, Tail], Flags]] } }(f) def transform[ From: Type, To: Type, - Cfg <: TransformerOverrides: Type, + Tail <: TransformerOverrides: Type, Flags <: TransformerFlags: Type, ImplicitScopeFlags <: TransformerFlags: Type ]( source: Expr[From], - td: Expr[TransformerDefinition[From, To, Cfg, Flags]] + td: Expr[TransformerDefinition[From, To, Tail, Flags]] )(using Quotes): Expr[To] = - TransformerMacros.deriveTotalTransformerResultWithConfig[From, To, Cfg, Flags, ImplicitScopeFlags](source, td) + TransformerMacros.deriveTotalTransformerResultWithConfig[From, To, Tail, Flags, ImplicitScopeFlags](source, td) } diff --git a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala index 189f8920f..128e1d406 100644 --- a/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala +++ b/chimney/src/main/scala-3/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala @@ -49,14 +49,13 @@ private[chimney] class DslMacroUtils()(using quotes: Quotes) { }) case _: Ident => Left(ignoringInputNotAllowed(t)) case SelectLike(t2, fieldName) => - unpackSelects(t2).map { instance => + unpackSelects(t2).map { init => val name = ExistentialString(fieldName) - import instance.Underlying as Instance - import name.Underlying as FieldName + import init.Underlying as Init, name.Underlying as FieldName new ExistentialPath { - type Underlying = runtime.Path.Select[FieldName, Instance] - val Underlying: Type[runtime.Path.Select[FieldName, Instance]] = - Type.of[runtime.Path.Select[FieldName, Instance]] + type Underlying = runtime.Path.Select[Init, FieldName] + val Underlying: Type[runtime.Path.Select[Init, FieldName]] = + Type.of[runtime.Path.Select[Init, FieldName]] } } case Apply(_, _) => Left(arbitraryFunctionNotAllowed(t)) diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/ChimneyTypes.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/ChimneyTypes.scala index 0b1833e7d..d485f7690 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/ChimneyTypes.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/ChimneyTypes.scala @@ -235,15 +235,15 @@ private[compiletime] trait ChimneyTypes { this: ChimneyDefinitions => val Select: SelectModule trait SelectModule extends Type.Ctor2UpperBounded[ - String, runtime.Path, + String, runtime.Path.Select ] { this: Select.type => } val Match: MatchModule trait MatchModule extends Type.Ctor2UpperBounded[ - Any, runtime.Path, + Any, runtime.Path.Match ] { this: Match.type => } } diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Configurations.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Configurations.scala index 5a8f5047c..c285e2b30 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Configurations.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Configurations.scala @@ -62,13 +62,13 @@ private[compiletime] trait Configurations { this: Derivation => // TODO: rename Config => Configuration final def readPatcherConfig[ - Cfg <: runtime.PatcherOverrides: Type, + Tail <: runtime.PatcherOverrides: Type, Flags <: runtime.PatcherFlags: Type, ImplicitScopeFlags <: runtime.PatcherFlags: Type ]: PatcherConfiguration = { val implicitScopeFlags = extractTransformerFlags[ImplicitScopeFlags](PatcherFlags()) val allFlags = extractTransformerFlags[Flags](implicitScopeFlags) - extractPatcherConfig[Cfg]().copy(flags = allFlags) + extractPatcherConfig[Tail]().copy(flags = allFlags) } private def extractTransformerFlags[Flags <: runtime.PatcherFlags: Type](defaultFlags: PatcherFlags): PatcherFlags = @@ -86,10 +86,11 @@ private[compiletime] trait Configurations { this: Derivation => // $COVERAGE-ON$ } - private def extractPatcherConfig[Cfg <: runtime.PatcherOverrides: Type](): PatcherConfiguration = Type[Cfg] match { - case empty if empty =:= ChimneyType.PatcherOverrides.Empty => PatcherConfiguration() - case _ => - reportError(s"Invalid internal PatcherOverrides type shape: ${Type.prettyPrint[Cfg]}!!") - } + private def extractPatcherConfig[Tail <: runtime.PatcherOverrides: Type](): PatcherConfiguration = + Type[Tail] match { + case empty if empty =:= ChimneyType.PatcherOverrides.Empty => PatcherConfiguration() + case _ => + reportError(s"Invalid internal PatcherOverrides type shape: ${Type.prettyPrint[Tail]}!!") + } } } diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Gateway.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Gateway.scala index b05c2325b..504514e67 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Gateway.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/Gateway.scala @@ -12,7 +12,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => final def derivePatcherResult[ A: Type, Patch: Type, - Cfg <: runtime.PatcherOverrides: Type, + Tail <: runtime.PatcherOverrides: Type, Flags <: runtime.PatcherFlags: Type, ImplicitScopeFlags <: runtime.PatcherFlags: Type ]( @@ -24,7 +24,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => .create[A, Patch]( obj, patch, - config = PatcherConfigurations.readPatcherConfig[Cfg, Flags, ImplicitScopeFlags] + config = PatcherConfigurations.readPatcherConfig[Tail, Flags, ImplicitScopeFlags] ) .updateConfig(_.allowAPatchImplicitSearch) @@ -40,7 +40,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => final def derivePatcher[ A: Type, Patch: Type, - Cfg <: runtime.PatcherOverrides: Type, + Tail <: runtime.PatcherOverrides: Type, Flags <: runtime.PatcherFlags: Type, ImplicitScopeFlags <: runtime.PatcherFlags: Type ]: Expr[Patcher[A, Patch]] = { @@ -49,7 +49,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => val context = PatcherContext.create[A, Patch]( obj, patch, - config = PatcherConfigurations.readPatcherConfig[Cfg, Flags, ImplicitScopeFlags] + config = PatcherConfigurations.readPatcherConfig[Tail, Flags, ImplicitScopeFlags] ) await(enableLoggingIfFlagEnabled(derivePatcherResultExpr(context), context)) diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Configurations.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Configurations.scala index dbc12ffa7..e2c512cd1 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Configurations.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Configurations.scala @@ -175,7 +175,7 @@ private[compiletime] trait Configurations { this: Derivation => final protected case class TransformerConfiguration( flags: TransformerFlags = TransformerFlags(), /** Let us distinct if flags were modified only by implicit TransformerConfiguration or maybe also locally */ - private val instanceFlagOverridden: Boolean = false, + private val localFlagsOverridden: Boolean = false, /** Stores all customizations provided by user */ private val runtimeOverrides: Vector[(Path, TransformerOverride)] = Vector.empty, /** Let us prevent `implicit val foo = foo` but allow `implicit val foo = new Foo { def sth = foo }` */ @@ -200,39 +200,38 @@ private[compiletime] trait Configurations { this: Derivation => } def setLocalFlagsOverriden: TransformerConfiguration = - copy(instanceFlagOverridden = true) - def areLocalFlagsOverridesEmptyForCurrent: Boolean = - !instanceFlagOverridden + copy(localFlagsOverridden = true) + def areLocalFlagsEmpty: Boolean = + !localFlagsOverridden def addTransformerOverride(path: Path, runtimeOverride: TransformerOverride): TransformerConfiguration = copy(runtimeOverrides = runtimeOverrides :+ (path -> runtimeOverride)) - def areValueOverridesEmptyForCurrent: Boolean = + def areOverridesEmpty: Boolean = runtimeOverrides.isEmpty - def areOverridesEmptyForCurrent: Boolean = - areLocalFlagsOverridesEmptyForCurrent && areValueOverridesEmptyForCurrent - def filterOverridesForField(nameFilter: String => Boolean): Map[String, TransformerOverride.ForField] = + def areLocalFlagsAndOverridesEmpty: Boolean = + areLocalFlagsEmpty && areOverridesEmpty + def filterCurrentOverridesForField(nameFilter: String => Boolean): Map[String, TransformerOverride.ForField] = ListMap.from( runtimeOverridesForCurrent.collect { case (Path.AtField(name, _), runtimeFieldOverride: TransformerOverride.ForField) if nameFilter(name) => name -> runtimeFieldOverride } ) - def filterOverridesForCoproduct(typeFilter: ?? => Boolean): Map[??, TransformerOverride.ForSubtype] = + def filterCurrentOverridesForSubtype(typeFilter: ?? => Boolean): Map[??, TransformerOverride.ForSubtype] = ListMap.from( runtimeOverridesForCurrent.collect { case (Path.AtSubtype(tpe, _), runtimeCoproductOverride: TransformerOverride.ForSubtype) if typeFilter(tpe) => tpe -> runtimeCoproductOverride } ) - def filterOverridesForConstructor: Option[TransformerOverride.ForConstructor] = + def currentOverrideForConstructor: Option[TransformerOverride.ForConstructor] = runtimeOverridesForCurrent.collectFirst { - case (_, runtimeConstructorOverride: TransformerOverride.ForConstructor) => - runtimeConstructorOverride + case (_, runtimeConstructorOverride: TransformerOverride.ForConstructor) => runtimeConstructorOverride } def prepareForRecursiveCall(toPath: Path)(implicit ctx: TransformationContext[?, ?]): TransformerConfiguration = copy( - instanceFlagOverridden = false, + localFlagsOverridden = false, runtimeOverrides = for { (path, runtimeOverride) <- runtimeOverrides alwaysDropOnRoot = runtimeOverride match { @@ -257,7 +256,7 @@ private[compiletime] trait Configurations { this: Derivation => }.toString s"""TransformerConfig( | flags = $flags, - | instanceFlagOverridden = $instanceFlagOverridden, + | localFlagsOverridden = $localFlagsOverridden, | runtimeOverrides = Vector($runtimeOverridesString), | preventImplicitSummoningForTypes = $preventImplicitSummoningForTypesString |)""".stripMargin @@ -269,13 +268,13 @@ private[compiletime] trait Configurations { this: Derivation => // TODO: rename Config => Configuration final def readTransformerConfig[ - Cfg <: runtime.TransformerOverrides: Type, + Tail <: runtime.TransformerOverrides: Type, InstanceFlags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]: TransformerConfiguration = { val implicitScopeFlags = extractTransformerFlags[ImplicitScopeFlags](TransformerFlags()) val allFlags = extractTransformerFlags[InstanceFlags](implicitScopeFlags) - val cfg = extractTransformerConfig[Cfg](runtimeDataIdx = 0).copy(flags = allFlags) + val cfg = extractTransformerConfig[Tail](runtimeDataIdx = 0).copy(flags = allFlags) if (Type[InstanceFlags] =:= ChimneyType.TransformerFlags.Default) cfg else cfg.setLocalFlagsOverriden } @@ -347,87 +346,87 @@ private[compiletime] trait Configurations { this: Derivation => // $COVERAGE-ON$ } - private def extractTransformerConfig[Cfg <: runtime.TransformerOverrides: Type]( + private def extractTransformerConfig[Tail <: runtime.TransformerOverrides: Type]( runtimeDataIdx: Int - ): TransformerConfiguration = Type[Cfg] match { + ): TransformerConfiguration = Type[Tail] match { case empty if empty =:= ChimneyType.TransformerOverrides.Empty => TransformerConfiguration() case ChimneyType.TransformerOverrides.Const(toPath, cfg) => - import toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.Const(runtimeDataIdx) ) case ChimneyType.TransformerOverrides.ConstPartial(toPath, cfg) => - import toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.ConstPartial(runtimeDataIdx) ) case ChimneyType.TransformerOverrides.Computed(toPath, cfg) => - import toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.Computed(runtimeDataIdx) ) case ChimneyType.TransformerOverrides.ComputedPartial(toPath, cfg) => - import toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.ComputedPartial(runtimeDataIdx) ) case ChimneyType.TransformerOverrides.CaseComputed(toPath, cfg) => - import toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.CaseComputed(runtimeDataIdx) ) case ChimneyType.TransformerOverrides.CaseComputedPartial(toPath, cfg) => - import toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.CaseComputedPartial(runtimeDataIdx) ) case ChimneyType.TransformerOverrides.Constructor(args, toPath, cfg) => - import args.Underlying as Args, toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import args.Underlying as Args, toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.Constructor(runtimeDataIdx, extractArgumentLists[Args]) ) case ChimneyType.TransformerOverrides.ConstructorPartial(args, toPath, cfg) => - import args.Underlying as Args, toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](1 + runtimeDataIdx) + import args.Underlying as Args, toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](1 + runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.ConstructorPartial(runtimeDataIdx, extractArgumentLists[Args]) ) case ChimneyType.TransformerOverrides.RenamedFrom(fromPath, toPath, cfg) => - import fromPath.Underlying as FromPath, toPath.Underlying as ToPath, cfg.Underlying as Cfg2 - extractTransformerConfig[Cfg2](runtimeDataIdx) + import fromPath.Underlying as FromPath, toPath.Underlying as ToPath, cfg.Underlying as Tail2 + extractTransformerConfig[Tail2](runtimeDataIdx) .addTransformerOverride( extractPath[ToPath], TransformerOverride.RenamedFrom(extractPath[FromPath]) ) case _ => // $COVERAGE-OFF$ - reportError(s"Invalid internal TransformerOverrides type shape: ${Type.prettyPrint[Cfg]}!!") + reportError(s"Invalid internal TransformerOverrides type shape: ${Type.prettyPrint[Tail]}!!") // $COVERAGE-ON$ } private def extractPath[PathType <: runtime.Path: Type]: Path = Type[PathType] match { case root if root =:= ChimneyType.Path.Root => Path.Root - case ChimneyType.Path.Select(fieldName, path) => - import fieldName.Underlying as FieldName, path.Underlying as PathType2 + case ChimneyType.Path.Select(init, fieldName) => + import init.Underlying as PathType2, fieldName.Underlying as FieldName extractPath[PathType2].select(Type[FieldName].extractStringSingleton) - case ChimneyType.Path.Match(subtype, path) => - import subtype.Underlying as Subtype, path.Underlying as PathType2 + case ChimneyType.Path.Match(init, subtype) => + import init.Underlying as PathType2, subtype.Underlying as Subtype extractPath[PathType2].`match`[Subtype] case _ => // $COVERAGE-OFF$ diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Gateway.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Gateway.scala index c9bd5e654..eaed8c42c 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Gateway.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/Gateway.scala @@ -16,7 +16,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => final def deriveTotalTransformationResult[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Tail <: runtime.TransformerOverrides: Type, InstanceFlags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( @@ -27,7 +27,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => val context = TransformationContext.ForTotal .create[From, To]( src, - TransformerConfigurations.readTransformerConfig[Cfg, InstanceFlags, ImplicitScopeFlags], + TransformerConfigurations.readTransformerConfig[Tail, InstanceFlags, ImplicitScopeFlags], runtimeDataStore ) .updateConfig(_.allowFromToImplicitSummoning) @@ -44,7 +44,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => final def deriveTotalTransformer[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Tail <: runtime.TransformerOverrides: Type, InstanceFlags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( @@ -55,7 +55,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => val context = TransformationContext.ForTotal .create[From, To]( src, - TransformerConfigurations.readTransformerConfig[Cfg, InstanceFlags, ImplicitScopeFlags], + TransformerConfigurations.readTransformerConfig[Tail, InstanceFlags, ImplicitScopeFlags], runtimeDataStore ) @@ -72,7 +72,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => final def derivePartialTransformationResult[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Tail <: runtime.TransformerOverrides: Type, InstanceFlags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( @@ -85,7 +85,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => .create[From, To]( src, failFast, - TransformerConfigurations.readTransformerConfig[Cfg, InstanceFlags, ImplicitScopeFlags], + TransformerConfigurations.readTransformerConfig[Tail, InstanceFlags, ImplicitScopeFlags], runtimeDataStore ) .updateConfig(_.allowFromToImplicitSummoning) @@ -102,7 +102,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => final def derivePartialTransformer[ From: Type, To: Type, - Cfg <: runtime.TransformerOverrides: Type, + Tail <: runtime.TransformerOverrides: Type, InstanceFlags <: runtime.TransformerFlags: Type, ImplicitScopeFlags <: runtime.TransformerFlags: Type ]( @@ -114,7 +114,7 @@ private[compiletime] trait Gateway extends GatewayCommons { this: Derivation => .create[From, To]( src, failFast, - TransformerConfigurations.readTransformerConfig[Cfg, InstanceFlags, ImplicitScopeFlags], + TransformerConfigurations.readTransformerConfig[Tail, InstanceFlags, ImplicitScopeFlags], runtimeDataStore ) diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformImplicitRuleModule.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformImplicitRuleModule.scala index 6c1ec325f..0c57cecf1 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformImplicitRuleModule.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformImplicitRuleModule.scala @@ -9,7 +9,7 @@ private[compiletime] trait TransformImplicitRuleModule { this: Derivation => protected object TransformImplicitRule extends Rule("Implicit") { def expand[From, To](implicit ctx: TransformationContext[From, To]): DerivationResult[Rule.ExpansionResult[To]] = - if (ctx.config.areOverridesEmptyForCurrent) transformWithImplicitIfAvailable[From, To] + if (ctx.config.areLocalFlagsAndOverridesEmpty) transformWithImplicitIfAvailable[From, To] else DerivationResult.attemptNextRuleBecause("Configuration has defined overrides") private def transformWithImplicitIfAvailable[From, To](implicit diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformProductToProductRuleModule.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformProductToProductRuleModule.scala index 1c7d5321e..1f25c4f64 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformProductToProductRuleModule.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformProductToProductRuleModule.scala @@ -31,7 +31,7 @@ private[compiletime] trait TransformProductToProductRuleModule { this: Derivatio def unapply[A, From, To]( tpe: Type[A] )(implicit ctx: TransformationContext[From, To]): Option[TransformerOverride.ForConstructor] = - ctx.config.filterOverridesForConstructor + ctx.config.currentOverrideForConstructor } private def mapOverridesAndExtractorsToConstructorArguments[From, To]( @@ -90,7 +90,7 @@ private[compiletime] trait TransformProductToProductRuleModule { this: Derivatio val verifyNoOverrideUnused = Traverse[List] .parTraverse( - filterOverridesForField(usedToName => + filterCurrentOverridesForField(usedToName => !parameters.keys.exists(toName => areFieldNamesMatching(usedToName, toName)) ).keys.toList ) { fromName => @@ -168,8 +168,8 @@ private[compiletime] trait TransformProductToProductRuleModule { this: Derivatio // User might have used _.getName in modifier, to define target we know as _.setName so simple .get(toName) // might not be enough. However, we DO want to prioritize strict name matches. - filterOverridesForField(_ == toName).headOption - .orElse(filterOverridesForField(areFieldNamesMatching(_, toName)).headOption) + filterCurrentOverridesForField(_ == toName).headOption + .orElse(filterCurrentOverridesForField(areFieldNamesMatching(_, toName)).headOption) .map { case AmbiguousOverrides(overrideName, foundOverrides) => DerivationResult.ambiguousFieldOverrides[From, To, Existential[TransformationExpr]]( diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSealedHierarchyToSealedHierarchyRuleModule.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSealedHierarchyToSealedHierarchyRuleModule.scala index 10947a48c..6f8368a0b 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSealedHierarchyToSealedHierarchyRuleModule.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSealedHierarchyToSealedHierarchyRuleModule.scala @@ -57,7 +57,7 @@ private[compiletime] trait TransformSealedHierarchyToSealedHierarchyRuleModule { private def mapOverriddenElements[From, To](implicit ctx: TransformationContext[From, To] ): List[Existential[ExprPromise[*, TransformationExpr[To]]]] = ctx.config - .filterOverridesForCoproduct { someFrom => + .filterCurrentOverridesForSubtype { someFrom => import someFrom.Underlying as SomeFrom Type[SomeFrom] <:< Type[From] } diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSubtypesRuleModule.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSubtypesRuleModule.scala index df2c45a81..386960485 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSubtypesRuleModule.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformSubtypesRuleModule.scala @@ -9,7 +9,7 @@ private[compiletime] trait TransformSubtypesRuleModule { this: Derivation => def expand[From, To](implicit ctx: TransformationContext[From, To]): DerivationResult[Rule.ExpansionResult[To]] = if (Type[From] <:< Type[To]) { - if (ctx.config.areOverridesEmptyForCurrent) transformByUpcasting[From, To] + if (ctx.config.areLocalFlagsAndOverridesEmpty) transformByUpcasting[From, To] else DerivationResult.attemptNextRuleBecause("Configuration has defined overrides") } else DerivationResult.attemptNextRule diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformTypeToValueClassRuleModule.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformTypeToValueClassRuleModule.scala index bf891b0b4..aa105059a 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformTypeToValueClassRuleModule.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformTypeToValueClassRuleModule.scala @@ -11,7 +11,7 @@ private[compiletime] trait TransformTypeToValueClassRuleModule { def expand[From, To](implicit ctx: TransformationContext[From, To]): DerivationResult[Rule.ExpansionResult[To]] = Type[To] match { case ValueClassType(to2) => - if (ctx.config.areValueOverridesEmptyForCurrent) { + if (ctx.config.areOverridesEmpty) { import to2.{Underlying as InnerTo, value as valueTo} transformToInnerToAndWrap[From, To, InnerTo](valueTo) } else DerivationResult.attemptNextRuleBecause("Configuration has defined overrides") diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToTypeRuleModule.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToTypeRuleModule.scala index b79cd4196..e8a0c6e03 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToTypeRuleModule.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToTypeRuleModule.scala @@ -11,7 +11,7 @@ private[compiletime] trait TransformValueClassToTypeRuleModule { def expand[From, To](implicit ctx: TransformationContext[From, To]): DerivationResult[Rule.ExpansionResult[To]] = Type[From] match { case ValueClassType(from2) => - if (ctx.config.areValueOverridesEmptyForCurrent) { + if (ctx.config.areOverridesEmpty) { import from2.{Underlying as InnerFrom, value as valueFrom} unwrapAndTransform[From, To, InnerFrom](valueFrom) } else DerivationResult.attemptNextRuleBecause("Configuration has defined overrides") diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToValueClassRuleModule.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToValueClassRuleModule.scala index 616d9d06b..99acd6e4b 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToValueClassRuleModule.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/transformer/rules/TransformValueClassToValueClassRuleModule.scala @@ -10,7 +10,7 @@ private[compiletime] trait TransformValueClassToValueClassRuleModule { this: Der def expand[From, To](implicit ctx: TransformationContext[From, To]): DerivationResult[Rule.ExpansionResult[To]] = (Type[From], Type[To]) match { case (ValueClassType(from2), ValueClassType(to2)) => - if (ctx.config.areValueOverridesEmptyForCurrent) { + if (ctx.config.areOverridesEmpty) { import from2.{Underlying as InnerFrom, value as valueFrom}, to2.{Underlying as InnerTo, value as valueTo} unwrapTransformAndWrapAgain[From, To, InnerFrom, InnerTo](valueFrom, valueTo) } else DerivationResult.attemptNextRuleBecause("Configuration has defined overrides") diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/Path.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/Path.scala index ebe42ed6b..964109c58 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/Path.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/Path.scala @@ -3,6 +3,6 @@ package io.scalaland.chimney.internal.runtime sealed abstract class Path object Path { final class Root extends Path - final class Select[Name <: String, Instance <: Path] extends Path - final class Match[Subtype, Instance <: Path] extends Path + final class Select[Init <: Path, FieldName <: String] extends Path + final class Match[Init <: Path, Subtype] extends Path } diff --git a/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/TransformerOverrides.scala b/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/TransformerOverrides.scala index be16d314f..9eb6430ac 100644 --- a/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/TransformerOverrides.scala +++ b/chimney/src/main/scala/io/scalaland/chimney/internal/runtime/TransformerOverrides.scala @@ -6,17 +6,17 @@ sealed abstract class TransformerOverrides object TransformerOverrides { final class Empty extends Overrides // Provides a precomputed value - final class Const[ToPath <: Path, Cfg <: Overrides] extends Overrides - final class ConstPartial[ToPath <: Path, Cfg <: Overrides] extends Overrides + final class Const[ToPath <: Path, Tail <: Overrides] extends Overrides + final class ConstPartial[ToPath <: Path, Tail <: Overrides] extends Overrides // Computes a value from a whole (src: From) - final class Computed[ToPath <: Path, Cfg <: Overrides] extends Overrides - final class ComputedPartial[ToPath <: Path, Cfg <: Overrides] extends Overrides + final class Computed[ToPath <: Path, Tail <: Overrides] extends Overrides + final class ComputedPartial[ToPath <: Path, Tail <: Overrides] extends Overrides // Computes a value from an already extracted (e.g. matched) piece of (src: From) - final class CaseComputed[ToPath <: Path, Cfg <: Overrides] extends Overrides - final class CaseComputedPartial[ToPath <: Path, Cfg <: Overrides] extends Overrides + final class CaseComputed[ToPath <: Path, Tail <: Overrides] extends Overrides + final class CaseComputedPartial[ToPath <: Path, Tail <: Overrides] extends Overrides // Computes a value after all constructor arguments have been matched - final class Constructor[Args <: ArgumentLists, ToPath <: Path, Cfg <: Overrides] extends Overrides - final class ConstructorPartial[Args <: ArgumentLists, ToPath <: Path, Cfg <: Overrides] extends Overrides + final class Constructor[Args <: ArgumentLists, ToPath <: Path, Tail <: Overrides] extends Overrides + final class ConstructorPartial[Args <: ArgumentLists, ToPath <: Path, Tail <: Overrides] extends Overrides // Computes a value using manually pointed value from (src: From) - final class RenamedFrom[FromPath <: Path, ToPath <: Path, Cfg <: Overrides] extends Overrides + final class RenamedFrom[FromPath <: Path, ToPath <: Path, Tail <: Overrides] extends Overrides }