MakeAWishFoundation/SwiftyMocky

Missing parenthesis optional existential type (any ProtocolName) properties

p4t5h3 opened this issue · 0 comments

p4t5h3 commented

Having this protocol:

protocol MyProtocol { // sourcery: AutoMockable
    var item: (any AnotherProtocol)? { get set }
}

I get this property in my generated mock code:

public var item: any AnotherProtocol? {
    get {	invocations.append(.p_item_get); return __p_item ?? optionalGivenGetterValue(.p_item_get, "MyProtocolMock - stub value for item was not defined") }
    set {	invocations.append(.p_item_set(.value(newValue))); __p_item = newValue }
}

With the compiler error:

Optional 'any' type must be written '(any AnotherProtocol)?'

I am using:

  • Sourcery 1.9.2 installed via Mint or 2.0.0 installed via Homebrew (checked both and altered my sourceryCommand accordingly)
  • SwiftyMocky CLI v4.2.0
  • Swift 5.7.2 (Xcode 14.2 (14C18))

Obviously the expectation and correct code generation is any AnotherProtocol wrapped in parenthesis.

Am I doing something wrong? Is this not supported yet? Is this actually a SwiftyMocky or Sourcery issue? I always an insecure about the latter when encountering issues. 😁 Strangely, I have not found any existing issue for this.