mattpolzin / JSONAPI

Swift Codable JSON:API framework
MIT License
75 stars 19 forks source link

Warning: Redundant constrant on Transformer #90

Open swgamerx opened 3 years ago

swgamerx commented 3 years ago

Describe the bug Getting a compile warning on Attribute.swift on line 39 for extension TransformedAttribute "Redundant conformance constraint 'Transformer' : 'Transformer'.

Platform (only for runtime bugs): MacOS 11.0.1 Xcode 12.2

Context JSONAPI is included and installed as a CocoaPod but not imported or used in code, just having it available throws the warning.

Do you plan to fix yourself? I might but It's a bit beyond my understanding at the moment.

mattpolzin commented 3 years ago

This is an annoying warning that showed up some time ago (via a new Swift version, I forget which one) and has changed a bit with each new Swift version but never gone away.

I am not really sure how else to formulate the line it warns about; the line in question is not simply redeclaring conformance to Transformer, but rather further specializing to Transformer specifically being equal to IdentityTransformer.

If you find another way to write the code, let me know! The only thing I have come up with is using Transformer.From == Transformer.To instead of Transformer == IdentityTransformer<RawValue> but that has a different meaning and although it might work almost as well, I don't want to bet that on a minor patch that fixes a warning but might actually cause a regression for someone else's code.

swgamerx commented 3 years ago

I assumed it must be related to some XCode changes or the newer version of Swift, I just thought It might be worth documenting even though it's just a warning. I'll take a swing at it but you understand it 1000x more than I do, but it could be a good learning experiencing to dig around it.