-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full compatibility with the "ExistentialAny" upcoming feature #99
Conversation
@swift-server-bot add to allowlist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MahdiBM thanks for the contribution!
Hi @MahdiBM, thanks for helping us prepare for Swift 6! I'm generally in favor of this change, and I'd actually like it done even more holistically:
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above – glad to see this, just a few things needed.
Generally, as i understand, the "upcoming feature" flags are all accepted and confirmed for Swift 6. The proposal: https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md
The proposal mentions Swift 5.6 as the lowest version.
We could use it in the whole generator as well, so the code of the generator itself is forced to use existential anys. That's not 100% related to the generated code though so i will still need to look into enabling the flag for integration tests as well.
I agree. Does that mean i should create a new "TypeDescription" struct instead and use that instead of just a simple string for type names in |
👍
Great, so we can adopt it right away, as we require 5.8.
I don't want to feature-creep your PR too much, but if you try to enable it across the board in the project, even for the generator code itself, and it doesn't require too many changes, let's do it all here. If it requires any non-trivial changes, we'll break it out into a separate issue, and just focus this PR on adding
Let's just use a simple string for now. After re-reading SE-335, the |
Yeah it's not a problem
👍 |
@czechboy0 I can add the upcoming flag to the swift build command (in the CI script), but i think you should just add it to the swift settings of targets of the test package in Package.swift (like in this PR)... Do you want to do that or should i just add it to the swift build command? |
I think Package.swift is the right place. Would you also be open to adding this to swift-openapi-runtime, and possibly swift-openapi-urlsession and swift-openapi-async-http-client? Feel free to say no, and I'll file it as a separate issue, I just like the change and would like it to have across the board 🙂 |
Sure that's no problem 🙂 |
@czechboy0 One question, is this PR waiting on me adding existential-any to the other projects as well? Because i don't think this PR should need any of those for it to be merged (it doesn't make any of those fail to build/compile or anything. It's completely "backward compatible" as we're already using it with no-existential-any openapi-runtime and async-http-client-generator) |
Thanks, @MahdiBM! 👏 |
Discussed and requested in apple/swift-openapi-generator#99 (comment)
Discussed and requested in apple/swift-openapi-generator#99 (comment)
Adopt explicit existential any ### Motivation As a follow-on to apple/swift-openapi-generator#99, let's also enable explicit existential any in the runtime library. ### Modifications Enabled the flag in Package.swift (for Swift 5.9 and newer) and updated all the usage sites. ### Result The codebase is closer to being ready for Swift 6. ### Test Plan Updated unit tests as well, all is passing locally. Reviewed by: simonjbeaumont Builds: ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (docc test) - Build finished. ✔︎ pull request validation (integration test) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. ✖︎ pull request validation (api breakage) - Build finished. #26
Motivation
The generated code doesn't use existential any which disables the user targets of this package to enable the
.enableUpcomingFeature("ExistentialAny")
swift settings.The code of the generator itself is also not compatible with the mentioned flag, which is suboptimal as this is going to be required for Swift 6.
Modifications
Always use existential any in the generated code. An exhaustive list of the protocols I found which now use existential any:
any Decoder
any Encoder
any ClientTransport
any ServerTransport
any ClientMiddleware
any ServerMiddleware
And make the code of the package itself compatible with the
ExistentialAny
upcoming feature.Result
Both compatibility with users who wish to enable the
ExistentialAny
upcoming-feature flag on their targets, as well as being more ready for Swift 6.Test Plan
Modified the tests to reflect this change.
Considerations