Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code not confirm to protocol #414

Open
bupojung opened this issue Feb 6, 2022 · 3 comments
Open

Generated code not confirm to protocol #414

bupojung opened this issue Feb 6, 2022 · 3 comments

Comments

@bupojung
Copy link

bupojung commented Feb 6, 2022

this is the protocol

protocol PreviewVMOutput {
    typealias State = PreviewViewModel.State
    var previewState: Driver<State> { get }
    var previewAction: Signal<PreviewAction> { get }
}

generated code is:

class MockPreviewVMOutput: PreviewVMOutput, Cuckoo.ProtocolMock {

     typealias MocksType = PreviewVMOutput
    
     typealias Stubbing = __StubbingProxy_DKPreviewVMOutput
     typealias Verification = __VerificationProxy_DKPreviewVMOutput

     let cuckoo_manager = Cuckoo.MockManager.preconfiguredManager ?? Cuckoo.MockManager(hasParent: false)

    
    private var __defaultImplStub: PreviewVMOutput?

     func enableDefaultImplementation(_ stub: PreviewVMOutput) {
        __defaultImplStub = stub
        cuckoo_manager.enableDefaultStubImplementation()
    }
    

    
    
    
     var previewState: Driver<State> {
        get {
            return cuckoo_manager.getter("previewState",
                superclassCall:
                    
                    Cuckoo.MockManager.crashOnProtocolSuperclassCall()
                    ,
                defaultCall: __defaultImplStub!.previewState)
        }
        
    }
    
    
    
     var previewAction: Signal<PreviewAction> {
        get {
            return cuckoo_manager.getter("previewAction",
                superclassCall:
                    
                    Cuckoo.MockManager.crashOnProtocolSuperclassCall()
                    ,
                defaultCall: __defaultImplStub!.previewAction)
        }
        
    }
    

    

    

	 struct __StubbingProxy_DKPreviewVMOutput: Cuckoo.StubbingProxy {
	    private let cuckoo_manager: Cuckoo.MockManager
	
	     init(manager: Cuckoo.MockManager) {
	        self.cuckoo_manager = manager
	    }
	    
	    
	    var previewState: Cuckoo.ProtocolToBeStubbedReadOnlyProperty<MockPreviewVMOutput, Driver<State>> {
	        return .init(manager: cuckoo_manager, name: "previewState")
	    }
	    
	    
	    var previewAction: Cuckoo.ProtocolToBeStubbedReadOnlyProperty<MockPreviewVMOutput, Signal<PreviewAction>> {
	        return .init(manager: cuckoo_manager, name: "previewAction")
	    }
	    
	    
	}

	 struct __VerificationProxy_PreviewVMOutput: Cuckoo.VerificationProxy {
	    private let cuckoo_manager: Cuckoo.MockManager
	    private let callMatcher: Cuckoo.CallMatcher
	    private let sourceLocation: Cuckoo.SourceLocation
	
	     init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) {
	        self.cuckoo_manager = manager
	        self.callMatcher = callMatcher
	        self.sourceLocation = sourceLocation
	    }
	
	    
	    
	    var previewState: Cuckoo.VerifyReadOnlyProperty<Driver<State>> {
	        return .init(manager: cuckoo_manager, name: "previewState", callMatcher: callMatcher, sourceLocation: sourceLocation)
	    }
	    
	    
	    var previewAction: Cuckoo.VerifyReadOnlyProperty<Signal<PreviewAction>> {
	        return .init(manager: cuckoo_manager, name: "previewAction", callMatcher: callMatcher, sourceLocation: sourceLocation)
	    }
	    
	
	    
	}
}

and this code encounter two errors:

  1. Type 'MockPreviewVMOutput' does not conform to protocol 'PreviewVMOutput';
  2. Type of expression is ambiguous without more context
    image
@bupojung bupojung changed the title Not confirm to protocol Generated code not confirm to protocol Feb 6, 2022
@MatyasKriz
Copy link
Collaborator

MatyasKriz commented Feb 6, 2022

Seems to me like the problem is in Cuckoo not copying your typealias but still using just the aliased type.

I don't know if this is the case, but try to manually add the typealias into the mocked type to see if that's the reason. You need to disable mock generation to prevent it being overwritten for this test.

Another way to test this theory is to not use the typealias and instead the whole type.

@bupojung
Copy link
Author

bupojung commented Feb 8, 2022

Seems to me like the problem is in Cuckoo not copying your typealias but still using just the aliased type.

I don't know if this is the case, but try to manually add the typealias into the mocked type to see if that's the reason. You need to disable mock generation to prevent it being overwritten for this test.

Another way to test this theory is to not use the typealias and instead the whole type.

I use whole type instead resolve the error. thanks

@bupojung bupojung closed this as completed Feb 8, 2022
@MatyasKriz
Copy link
Collaborator

I'll reopen the issue if you don't mind, this is merely a workaround that shouldn't be necessary. This must be fixed on Cuckoo side.

@MatyasKriz MatyasKriz reopened this Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants