BetterCodable icon indicating copy to clipboard operation
BetterCodable copied to clipboard

[Fix] Generic Parameter Shadow Warning with Swift 5.9

Open FelixHerrmann opened this issue 2 years ago • 0 comments

With the release of Xcode 15 we now have Swift 5.9. With that there comes a new warning about shadowing generic parameters, see https://github.com/apple/swift/issues/62767. There is one place in this repository affected: Screenshot 2023-09-14 at 12 48 56

Implementation Details

It turns out that we don't need the generic parameter on this type at all, it's a private struct nested inside the type that already has the parameter defined, so there is no need to parse it through. Another approach would be to just rename the shadowed, inner parameter to something like V but IMO we should just remove it. Let me know if there are any concerns...

I have also fixed one failing test, the compare json had the opposite order compared to how it is defined in the CodingKeys.

Conclusion

This warning will be an error in Swift 6 so we should get that fix in, the sooner the better!

FelixHerrmann avatar Sep 14 '23 11:09 FelixHerrmann