diff options
author | Joe George <joe@zeroc.com> | 2024-11-04 13:25:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-04 13:25:57 -0500 |
commit | d27d388bf126e795b3ec28d188206bc6901406cf (patch) | |
tree | 9bf31ba40bf747e1d2c03b985c6b5174fa7b80b3 | |
parent | Fix IceSSL/configuration test failure (diff) | |
download | ice-d27d388bf126e795b3ec28d188206bc6901406cf.tar.bz2 ice-d27d388bf126e795b3ec28d188206bc6901406cf.tar.xz ice-d27d388bf126e795b3ec28d188206bc6901406cf.zip |
Swift 6 build fixes (#3051)
Adds support for Swift 6. Specifically it marks exceptions as `@unchecked Sendable` to comply with the error protocol requirements.
-rw-r--r-- | cpp/src/slice2swift/Gen.cpp | 1 | ||||
-rw-r--r-- | swift/src/Ice/Exception.swift | 14 |
2 files changed, 10 insertions, 5 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp index 0a7f28c6169..2529028e866 100644 --- a/cpp/src/slice2swift/Gen.cpp +++ b/cpp/src/slice2swift/Gen.cpp @@ -437,6 +437,7 @@ Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) { out << getUnqualified("Ice.UserException", swiftModule); } + out << ", @unchecked Sendable"; out << sb; const DataMemberList members = p->dataMembers(); diff --git a/swift/src/Ice/Exception.swift b/swift/src/Ice/Exception.swift index 474c9fa7e34..775deea2878 100644 --- a/swift/src/Ice/Exception.swift +++ b/swift/src/Ice/Exception.swift @@ -17,8 +17,10 @@ public extension Exception { } } -/// Base class for Ice run-time exceptions. -open class LocalException: Exception, CustomStringConvertible { +/// Base class for Ice run-time exceptions. Local exceptions are marked as "@unchecked Sendable" as the error +/// protocol requires them to be Sendable. However, the generated exception classes are not thread safe, and users +/// should not share instances of user exceptions between threads. +open class LocalException: Exception, CustomStringConvertible, @unchecked Sendable { public let file: String public let line: Int @@ -43,8 +45,10 @@ open class LocalException: Exception, CustomStringConvertible { } } -/// Base class for Ice user exceptions. -open class UserException: Exception { +/// Base class for Ice user exceptions. User exceptions are marked as "@unchecked Sendable" as the error +/// protocol requires them to be Sendable. However, the generated exception classes are not thread safe, and users +/// should not share instances of user exceptions between threads. +open class UserException: Exception, @unchecked Sendable { public required init() {} open func _iceReadImpl(from _: InputStream) throws {} @@ -83,7 +87,7 @@ open class UserException: Exception { } /// Error used to wrap C++ std::exception errors. -public class RuntimeError: LocalException { +public class RuntimeError: LocalException, @unchecked Sendable { private let message: String public override var description: String { |