Skip to content

Generated mock adds @escaping to init when dictionary has a function value #307

@jwsinner

Description

@jwsinner

Basic reproducer:

/// @mockable
protocol Tester {
  var testDictionary: [String: () -> String] { get }
}

Produces:

class TesterMock: Tester {
    init() { }
    init(testDictionary: @escaping [String: () -> String]) {
        self._testDictionary = testDictionary
    }

    private var _testDictionary: ([String: () -> String])! 
    var testDictionary: [String: () -> String] {
        get { return _testDictionary }
        set { _testDictionary = newValue }
    }
}

The @escaping in the init causes a compiler error due to it be associated with a dictionary rather than a function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions