-
Notifications
You must be signed in to change notification settings - Fork 128
Remove no-longer-needed @preconcurrency
s
#396
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
Conversation
@preconcurrency
s @preconcurrency
s
Should i also remove the |
apparently URL is still not Sendable. I thought it was. I'll modify the PR. |
Oh cool, thank you @MahdiBM! I wonder if we should do the same in the runtime repo, and the URLSession and AHC transports? |
I already have the runtime one ready, was waiting on your response 😅 Update: Somehow AHC is already "updated" since 4 months ago, by you. |
Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift
Outdated
Show resolved
Hide resolved
@swift-server-bot test this please |
16b3f39
to
614a535
Compare
@swift-server-bot test this please |
Same here, failing on 5.9.0 due to |
See apple/swift-openapi-generator#396. --------- Co-authored-by: Honza Dvorsky <[email protected]>
See apple/swift-openapi-generator#396. Co-authored-by: Honza Dvorsky <[email protected]>
@MahdiBM This one will be tricky, as the generated code doesn't know which version it'll run in, so it needs to work on 5.9.0, even if it produces remarks/warnings on newer Linux toolchains. |
I'm not sure I understand this comment. The generated code will still be compiled, just not by us. At the time of compilation we can still check Not counting the case where they fix more issues in Linux toolchains that aren't yet released; for prerelease toolchains we shouldn't expect to be warning-free 100% of the time. Maybe you were saying we cannot generate code that expects a certain version, the, yes, I agree: the generated code needs to handle all supported versions, but that doesn't mean we can't make it warning free for both Swift 5.9.0 and 5.9.1, or am I misunderstanding something? |
You're right, if we're willing to generate the conditional compilation code, which I guess there isn't a reason not to. |
Not only is there no reason not to, this is the only place where it matters. If adopters are compiling with warnings-as-errors then warnings in dependency libraries do not cause errors in the downstream build, but warnings in the generated code will. Appreciate in this case that these may be remarks or notes (cf. warnings), but in principle the generated code needs to be as clean as we can make it. |
Tests Please 🙂 |
@swift-server-bot test this please |
@czechboy0 ok that had some obvious problems. Another try please. Hopefully this one or next one should be good. |
@swift-server-bot test this please |
@MahdiBM you should be able to test this locally using:
|
@simonjbeaumont thanks, couldn't get that working earlier. |
I'm kind of lost why the 5.9.0 tests aren't passing: /// Types.swift:
#if canImport(Darwin) || swift(>=5.9.1)
import struct Foundation.Date
#else
@preconcurrency import struct Foundation.Date
#endif This results in this error: /code/Tests/PetstoreConsumerTests/Generated/Types.swift:1519:36: error: stored property 'createdAt' of 'Sendable'-conforming struct 'bodyPayload' has non-sendable type 'Date'
public var createdAt: Foundation.Date
^ Event removing the |
I think one reasonable way to go around this is to use the The solution is simple. Changing the test command: - command: /bin/bash -xcl "swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} $${STRICT_CONCURRENCY_ARG-}"
+ command: /bin/bash -xcl "swift build $${WARN_AS_ERROR_ARG-} $${STRICT_CONCURRENCY_ARG-} $${IMPORT_CHECK_ARG-} && swift $${SWIFT_TEST_VERB-test} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} $${STRICT_CONCURRENCY_ARG-}" (Replacing This makes it so the project is built using the |
@MahdiBM Are you saying this is a compiler bug? Can you file an issue on the Swift repo with a minimal repro case? I'd like to get a confirmation from them that this is really a bug that enough #if's can't solve before we turn off warnings-as-errors. |
To be honest it could be one of those cases where I'm getting something obvious wrong, but as far as I can tell, yes, I'm saying this is a compiler bug. I'm not sure how easy it'll be to catch it In a vaccum, but I can try. I'll also be happy if you could checkout this branch and run the Swift 5.9.0 tests locally and confirm it does seem suspicious to you. It should be as simple as you verifying that the compiler is emitting Date-not-Sendable warnings when @preconcurrency is already there for the Date import 🙂 |
We still have a long list of things we need to do for 1.0, so I won't be able to dig into this before then. Feel free to leave this PR open and move it to draft until post-1.0, then we can investigate further. |
Marking this as draft for now. |
Briefly tried to play with this today, but it's just too many changes at once to be able to test this between different versions. I wonder if you could actually break this up into individual PRs, each PR fixing a single type's remarks/warnings? That should allow us to take better advantage of CI instead of having to spend the time rerunning things locally. |
@czechboy0 Sure. I can break it down to 2 PRs: |
I'll close this then. |
Motivation
The closed-source Darwin Foundation had marked
Date
,Data
marked as Sendable for a long time.Now both swift-foundation and the swift-corelibs-foundation have them as Sendable as well on Swift 5.9 (5.9.1+ ?):
The PRs for swift corelibs-foundation can be found here.
We no longer need those
@preconcurrency
s.Modifications
Remove
@preconcurrency
s forFoundation.Date
,.Data
.Result
Less warnings in the logs.
Test Plan
Tested on Swift 5.9.1 on Linux.