@@ -564,16 +564,6 @@ object DeriveSchemaSpec extends ZIOSpecDefault with VersionSpecificDeriveSchemaS
564564 )
565565 assert(derived)(hasSameSchema(expected))
566566 },
567- test(
568- " correctly derives schema for sealed trait with intermediate traits, having leaf classes for Scala2"
569- ) {
570- intermediateTraitTest(enum2Annotations = Chunk .empty)
571- } @@ TestAspect .scala2Only,
572- test(
573- " correctly derives schema for sealed trait with intermediate traits, having leaf classes for Scala3"
574- ) {
575- intermediateTraitTest(enum2Annotations = Chunk (simpleEnum(automaticallyAdded = true )))
576- } @@ TestAspect .scala3Only,
577567 test(
578568 " correctly derives schema for abstract sealed class with intermediate subclasses, having case class leaf classes"
579569 ) {
@@ -628,62 +618,4 @@ object DeriveSchemaSpec extends ZIOSpecDefault with VersionSpecificDeriveSchemaS
628618 versionSpecificSuite
629619 )
630620
631- // Needed as I think is an unrelated existing bug in Scala 3 DeriveSchema whereby it adds simpleEnum annotation at the
632- // top level of the EnumN schema when one of the cases is a simple enum - however this does not happen with the Scala 2 macro.
633- // I think the Scala2 behavior is correct ie this should be a the leaf schema level.
634- // Create issue https://github.com/zio/zio-schema/issues/750 to track this
635- private def intermediateTraitTest (enum2Annotations : Chunk [Annotation ]) = {
636- val derived : Schema .Enum2 [TraitLeaf .type , MiddleTrait , TraitWithMiddleTrait ] =
637- DeriveSchema .gen[TraitWithMiddleTrait ]
638-
639- val middleTraitLeafSchema = Schema .CaseClass0 (
640- TypeId .fromTypeName(" zio.schema.DeriveSchemaSpec.MiddleTraitLeaf" ),
641- () => MiddleTraitLeaf ,
642- Chunk .empty
643- )
644- val middleTraitLeafCase = Schema .Case [MiddleTrait , MiddleTraitLeaf .type ](
645- " MiddleTraitLeaf" ,
646- middleTraitLeafSchema,
647- (a : MiddleTrait ) => a.asInstanceOf [MiddleTraitLeaf .type ],
648- (a : MiddleTraitLeaf .type ) => a.asInstanceOf [MiddleTrait ],
649- (a : MiddleTrait ) => a.isInstanceOf [MiddleTraitLeaf .type ]
650- )
651- val middleTraitSchema = Schema .Enum1 [MiddleTraitLeaf .type , MiddleTrait ](
652- TypeId .parse(" zio.schema.DeriveSchemaSpec.MiddleTrait" ),
653- middleTraitLeafCase,
654- Chunk (simpleEnum(automaticallyAdded = true ))
655- )
656-
657- val traitLeafSchema = Schema .CaseClass0 (
658- TypeId .fromTypeName(" zio.schema.DeriveSchemaSpec.TraitLeaf" ),
659- () => TraitLeaf ,
660- Chunk .empty
661- )
662- val traitLeafCase = Schema .Case [TraitWithMiddleTrait , TraitLeaf .type ](
663- " TraitLeaf" ,
664- traitLeafSchema,
665- (a : TraitWithMiddleTrait ) => a.asInstanceOf [TraitLeaf .type ],
666- (a : TraitLeaf .type ) => a.asInstanceOf [TraitWithMiddleTrait ],
667- (a : TraitWithMiddleTrait ) => a.isInstanceOf [TraitLeaf .type ]
668- )
669-
670- val middleTraitCase = Schema .Case [TraitWithMiddleTrait , MiddleTrait ](
671- " MiddleTrait" ,
672- middleTraitSchema,
673- (a : TraitWithMiddleTrait ) => a.asInstanceOf [MiddleTrait ],
674- (a : MiddleTrait ) => a.asInstanceOf [TraitWithMiddleTrait ],
675- (a : TraitWithMiddleTrait ) => a.isInstanceOf [MiddleTrait ]
676- )
677-
678- val expected =
679- Schema .Enum2 [TraitLeaf .type , MiddleTrait , TraitWithMiddleTrait ](
680- TypeId .parse(" zio.schema.DeriveSchemaSpec.TraitWithMiddleTrait" ),
681- traitLeafCase,
682- middleTraitCase,
683- enum2Annotations
684- )
685-
686- assert(derived)(hasSameSchema(expected))
687- }
688-
689621}
0 commit comments