You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
can be called with more than one mock, but that's more confusing than useful, because the following will not work:
reset(typeAMock, typeBMock)
The compiler will complain that typeBMock is not of the same type as typeAMock. The problem here is that M is bound to the type of the first parameter.
I don't see how this could be fixed with varargs as there is no common supertype that can be used here. So probably providing different versions with fixed parameter counts would be a useful workaround here
public func <M1: Mock>reset(_ mock1: M1)
public func <M1: Mock, M2: Mock>reset(_ mock1: M1, _ mock2: M2)
The text was updated successfully, but these errors were encountered:
I'll add one more protocol that will look like this:
protocol HasMockManager {
var manager: MockManager { get }
}
and the Mock protocol will be inheriting from this new one. Then the HasMockManager protocol won't have any associatedtype and will be possible to use for the reset function like so: func reset(_ mocks: HasMockManager...)
public func reset<M : Mock>(_ mocks: M...)
can be called with more than one mock, but that's more confusing than useful, because the following will not work:
reset(typeAMock, typeBMock)
The compiler will complain that
typeBMock
is not of the same type astypeAMock
. The problem here is thatM
is bound to the type of the first parameter.I don't see how this could be fixed with varargs as there is no common supertype that can be used here. So probably providing different versions with fixed parameter counts would be a useful workaround here
The text was updated successfully, but these errors were encountered: