Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ThijsBroersen committed Oct 16, 2024
1 parent fce70aa commit cc205a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,12 @@ private[magnolia] object AnnotationMacros:

val annotationTpe = TypeRepr.of[A]

def subTypeOf(tpe: TypeRepr, parent: TypeRepr): Boolean =
tpe.simplified.dealias match
case o: OrType =>
subTypeOf(o.left, parent) || subTypeOf(o.right, parent)
case o =>
tpe <:< parent

val annotations = TypeRepr
.of[T]
.typeSymbol
.annotations
.collect:
case term if subTypeOf(term.tpe, annotationTpe) => term
case term if term.tpe <:< annotationTpe => term

Expr.ofList(annotations.reverse.map(_.asExprOf[A]))
}
Expand All @@ -60,7 +53,7 @@ private[magnolia] object AnnotationMacros:
.map:
case (name, terms) =>
name -> terms.collect:
case term if term.tpe =:= annotationTpe => term
case term if term.tpe <:< annotationTpe => term
.map:
case (name, terms) => Expr(name) -> terms.reverse.map(_.asExprOf[A])
.map((name, annotations) => Expr.ofTuple((name, Expr.ofList(annotations))))
Expand Down
10 changes: 5 additions & 5 deletions magnolia/src/main/scala-3/zio/config/magnolia/DeriveConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ object DeriveConfig {
desc.metadata
) :: summonDeriveConfigForCoProduct[ts]

inline def summonDeriveConfigAll[T <: Tuple]: List[DeriveConfig[_]] =
inline def summonDeriveConfigAll[T <: Tuple]: List[DeriveConfig[?]] =
inline erasedValue[T] match
case _: EmptyTuple => Nil
case _: (t *: ts) =>
Expand Down Expand Up @@ -248,7 +248,7 @@ object DeriveConfig {

case None => Nil
}
}: _*
}*
)
}

Expand All @@ -258,7 +258,7 @@ object DeriveConfig {
defaultValues: Map[String, Any],
fieldNames: List[String],
descriptors: List[DeriveConfig[Any]]
): List[DeriveConfig[_]] =
): List[DeriveConfig[?]] =
descriptors.zip(fieldNames).map { case (desc, fieldName) =>
defaultValues.get(fieldName) match {
case Some(any) => DeriveConfig(desc.desc.withDefault(any), desc.metadata)
Expand All @@ -267,7 +267,7 @@ object DeriveConfig {
}

def mergeAllFields[T](
allDescs: => List[DeriveConfig[_]],
allDescs: => List[DeriveConfig[?]],
productName: ProductName,
fieldNames: => List[FieldName],
keyModifiers: List[KeyModifier],
Expand All @@ -292,7 +292,7 @@ object DeriveConfig {
}

val descOfList =
Config.collectAll(listOfDesc.head, listOfDesc.tail: _*)
Config.collectAll(listOfDesc.head, listOfDesc.tail*)

DeriveConfig(descOfList.map(f), Some(Metadata.Product(productName, fieldNames, keyModifiers)))

Expand Down
4 changes: 2 additions & 2 deletions magnolia/src/main/scala-3/zio/config/magnolia/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ val snakeCase: derivation.snakeCase.type = derivation.snakeCase
type prefix = derivation.prefix
val prefix: derivation.prefix.type = derivation.prefix

@deprecated("Use `suffix` instead", "4.0.3")
// @deprecated("Use `suffix` instead", "4.0.3")
type postfix = derivation.postfix
@deprecated("Use `suffix` instead", "4.0.3")
// @deprecated("Use `suffix` instead", "4.0.3")
val postfix: derivation.postfix.type = derivation.postfix

type suffix = derivation.suffix
Expand Down

0 comments on commit cc205a2

Please sign in to comment.