swift-spyable icon indicating copy to clipboard operation
swift-spyable copied to clipboard

Spy on protocol that confirms another protocol

Open alpha-moisol opened this issue 1 year ago • 10 comments

Is your feature request related to a problem? Please describe. When using @Spyable macro on protocol that confirms another protocol, there is no additional methods of confirmed protocol, which leads to compilation error. Eg:

protocol A {
    func a()
}

@Spyable
protocol B: A {
    func b() 
}

class BSpy: B {
    var bCallsCount = 0
    var bCalled: Bool {
        return bCallsCount > 0
    }
    var bClosure: (() -> Void)?
        func b() {
        bCallsCount += 1
        bClosure?()
    }
}

Describe the solution you'd like Would be great to have confirmed protocol methods in Spy class

alpha-moisol avatar Oct 26 '23 18:10 alpha-moisol