softwaremill / magnolia

Easy, fast, transparent generic derivation of typeclass instances
https://softwaremill.com/open-source/
Apache License 2.0
764 stars 116 forks source link

Fix providing annotations vs inherited annotations #529

Closed kciesielski closed 5 months ago

kciesielski commented 5 months ago

PR https://github.com/softwaremill/magnolia/pull/525 introduced changes to CollectAnnotations.fromDeclarations, causing incorrect creation of annotation list for class fields which override base trait fields: inheritedAnns returns an empty list, while anns returns a list containing both field annotations and inherited annotations. This problem slipped through tests, as we use a Show derivation which prints strings without differentiating field/inherited annotations. The issue has been detected in Tapir schema derivation tests.

This PR adjusts tests to include this distinction and fixes annotation extraction methods.