apple / swift-protobuf

Plugin and runtime library for using protobuf with Swift
Apache License 2.0
4.57k stars 449 forks source link

Swift 6 concurrency error on `_StorageClass.defaultInstance` #1729

Open rebello95 opened 3 weeks ago

rebello95 commented 3 weeks ago

When building with Xcode 16.0 and the Swift 6 toolchain, the following error occurs with a generated _StorageClass type:

Static property 'defaultInstance' is not concurrency-safe because non-'Sendable' type

Screenshot 2024-10-03 at 10 42 56 AM

I read through https://github.com/apple/swift-protobuf/issues/1560 which discussed this a bit, but based on this comment I opted to open a new issue.

This can reproduced on this Connect-Swift branch, but I think this is an issue with any generated _StorageClass when building with Swift 6.

thomasvl commented 2 weeks ago

@FranzBusch @gjcairo fyi - since I think you all mentioned working on full Swift 6 language mode. I guess starting with generated code would unblock folks first.

While #1561 might be sorta large to pull off in a non breaking way, I do wonder if that resolves a lot of this since I think the name map could get a lot simpler (no need for interning, etc.)

thomasvl commented 2 weeks ago

@tbkka fyi also

FranzBusch commented 2 weeks ago

since I think you all mentioned working on full Swift 6 language mode. I guess starting with generated code would unblock folks first.

I agree tackling the generated code is the most important thing. I do think we need to do all of this in a non-breaking way for now. Right now we are working through our other repos to make sure they compile without errors in Swift 6.

jhump commented 1 week ago

Do you have any idea of how soon this repo can be made compatible with Swift 6? We have a library that depends on this repo, and we're nearing a v1.0 release for it. We were hoping the v1.0 release could use Swift 6, but this issue is a blocker for that.