Skip to content

2.7.0

Latest

Choose a tag to compare

@github-actions github-actions released this 09 Oct 04:37
adde336

For Build Tools Plugin (artifactbundle)

.binaryTarget(
    name: "mockolo",
    url: "https://github.com/uber/mockolo/releases/download/2.7.0/mockolo.artifactbundle.zip",
    checksum: "cb07e8330133fde35b235307c764a2c50ee0ab074f53bfbcb2feecea8dfa0472"
),

New features

  • Add protocol-level @available annotation inheritance to generated mocks by @Keitaro0226 in #315

    /// @mockable
    @available(iOS 18.0, *)
    protocol Foo: Sendable {
        func bar()
    }
    
    // Before
    public final class FooMock: Foo, @unchecked Sendable { 
        // ❌ Missing @available
    }
    
    // After
    @available(iOS 18.0, *)
    public final class FooMock: Foo, @unchecked Sendable { 
    }
  • Fix member-level @available attributes hoisted to mock class declaration by @farkasseb in #352

    /// @mockable
    public protocol StorageInput: Sendable {
        func put(_ value: String, for key: String) async throws
        func string(for key: String) async throws -> String
    
        @available(*, noasync)
        @available(*, deprecated, message: "Use put(_:for:) async throws")
        @discardableResult func set(_ value: String, for key: String) -> Result<Void, Error>
    
        @available(*, noasync)
        @available(*, deprecated, message: "Use string(for:) async throws")
        func string(for key: String) -> Result<String, Error>
    }
    
    // Before — attributes from all deprecated members are concatenated onto the class declaration, causing a build error:
    @available(*, noasync)
        @available(*, deprecated, message: "Use put(_:for:) async throws")
        @discardableResult @available(*, noasync)
        @available(*, deprecated, message: "Use string(for:) async throws")
    public final class StorageInputMock: StorageInput, @unchecked Sendable {
        public var setCallCount: Int { ... }
        public func set(_ value: String, for key: String) -> Result<Void, Error> { ... }
        public func string(for key: String) -> Result<String, Error> { ... }
    }
    
    // After — only the protocol-conforming methods carry their own attributes:
    public final class StorageInputMock: StorageInput, @unchecked Sendable {
        public var setCallCount: Int { ... }
        public var setHandler: (...)? { ... }
        @available(*, noasync)
        @available(*, deprecated, message: "Use put(_:for:) async throws")
        public func set(_ value: String, for key: String) -> Result<Void, Error> { ... }
    
        public var stringForCallCount: Int { ... }
        public var stringForHandler: (...)? { ... }
        @available(*, noasync)
        @available(*, deprecated, message: "Use string(for:) async throws")
        public func string(for key: String) -> Result<String, Error> { ... }
    }

Fix bugs

  • Fix same-type where constraint generating non-generic type parameter in Swift 6 by @sidepelican with @Copilot in #348
  • Fix nested bracket type overloading by @sidepelican in #349
    • This is a breaking change.
    • The naming may change when overridden functions are mocked.
    protocol P {
        func update() -> Int
        func update() -> [String]
    }
    
    // Before
    class PMock: P {
        ...
        var updateStringHandler: (() -> [String])?
        ...
    }
    
    // After
    class PMock: P {
        ...
        var updateArrayStringHandler: (() -> [String])?
        ...
    }
  • Fix IUO type rendering so T! no longer generates T?! by @farkasseb in #354
  • Declare ArgValues arrays in type position by @farkasseb in #360

Maintenances

New Contributors

Full Changelog: 2.6.1...2.7.0