MakeAWishFoundation / SwiftyMocky

Framework for automatic mock generation. Adds a set of handy methods, simplifying testing. One of the best and most complete solutions, including generics support and much more.
MIT License
1.03k stars 104 forks source link

Missing parenthesis optional existential type (any ProtocolName) properties #338

Open p4t5h3 opened 1 year ago

p4t5h3 commented 1 year ago

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:

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.