uber / mockolo

Efficient Mock Generator for Swift
Apache License 2.0
813 stars 86 forks source link

Support `Sendable` compliant protocols and classes #254

Closed nhiroyasu closed 5 months ago

nhiroyasu commented 5 months ago

Summary

I have implemented the enhancements proposed in issue https://github.com/uber/mockolo/issues/252.

For mock classes that are required to conform to the Sendable protocol, I have made them inherit from @unchecked Sendable. This change should help reduce the number of unnecessary compiler warnings.

Examples

Source

protocol SendableProtocol: Sendable {}
class UncheckedSendableClass: @unchecked Sendable {}
final class SendableClass: Sendable {}
Output

class SendableProtocolMock: SendableProtocol, @unchecked Sendable {}
class UncheckedSendableClassMock: UncheckedSendableClass, @unchecked Sendable {}
// final class SendableClass is skipped, because final class can't make a mock class.

Previews

Before After
nhiroyasu commented 5 months ago

@sidepelican I have made the corrections to the areas you specified.