File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
zio-schema-derivation/shared/src Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -379,7 +379,7 @@ object DeriveSchema {
379
379
val getArg = TermName (fieldLabel)
380
380
381
381
val getFunc = q " (z: $tpe) => z. $getArg"
382
- val setFunc = q " (z: $tpe, v: ${ fieldType} ) => z.copy( $getArg = v) "
382
+ val setFunc = q " (z: $tpe, v: $fieldType) => z.copy[.. ${tpe.typeArgs} ] ( $getArg = v) "
383
383
384
384
if (annotations.nonEmpty) {
385
385
val newName = getFieldName(annotations).getOrElse(fieldLabel)
@@ -404,9 +404,9 @@ object DeriveSchema {
404
404
405
405
val constructExpr =
406
406
if (arity < 2 )
407
- q " defaultConstruct0 = (.. $constructArgs) => $tpeCompanion(.. $constructApplyArgs) "
407
+ q " defaultConstruct0 = (.. $constructArgs) => $tpeCompanion[.. ${tpe.typeArgs} ] (.. $constructApplyArgs) "
408
408
else
409
- q " construct0 = (.. $constructArgs) => $tpeCompanion(.. $constructApplyArgs) "
409
+ q " construct0 = (.. $constructArgs) => $tpeCompanion[.. ${tpe.typeArgs} ] (.. $constructApplyArgs) "
410
410
411
411
val applyArgs =
412
412
if (typeAnnotations.isEmpty)
Original file line number Diff line number Diff line change @@ -175,6 +175,12 @@ object DeriveSchemaSpec extends ZIOSpecDefault with VersionSpecificDeriveSchemaS
175
175
case class BLeaf [B ](value : B ) extends RBTree [Nothing , B ]
176
176
}
177
177
178
+ sealed trait AdtWithTypeParameters [+ Param1 , + Param2 ]
179
+
180
+ object AdtWithTypeParameters {
181
+ case class A [Param1 , Param2 ](fieldWithParam1 : Param1 ) extends AdtWithTypeParameters [Param1 , Param2 ]
182
+ case class B [Param1 , Param2 ](fieldWithParam2 : Param2 ) extends AdtWithTypeParameters [Param1 , Param2 ]
183
+ }
178
184
@ annotation1(" enum" ) sealed trait AnnotatedEnum
179
185
180
186
object AnnotatedEnum {
@@ -398,6 +404,10 @@ object DeriveSchemaSpec extends ZIOSpecDefault with VersionSpecificDeriveSchemaS
398
404
val derived : Schema [RBTree [String , Int ]] = DeriveSchema .gen[RBTree [String , Int ]]
399
405
assert(derived)(anything)
400
406
},
407
+ test(" correctly derives schema with unused type parameters" ) {
408
+ val derived : Schema [AdtWithTypeParameters [Int , Int ]] = DeriveSchema .gen[AdtWithTypeParameters [Int , Int ]]
409
+ assert(derived)(anything)
410
+ },
401
411
test(" correctly derives recursive Enum" ) {
402
412
assert(Schema [RecursiveEnum ].toString)(not(containsString(" null" )) && not(equalTo(" $Lazy$" )))
403
413
},
You can’t perform that action at this time.
0 commit comments