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

Throwing "'some' types are only permitted in properties, subscripts, and functions" when func throws & has some for its parameter #470

Open
enebin opened this issue Jun 10, 2023 · 2 comments
Labels

Comments

@enebin
Copy link

enebin commented Jun 10, 2023

First, I'd like to say I've really appreciated your works. It's pure amazement. However, there're a few issues blocking me to do further tasks. I brought some infos about it.

Reproducing code is here:

import SwiftUI

class SomeClass {
    func someMethod(_: some UIViewRepresentable) throws {
        
    }
}

It generates:

 struct __StubbingProxy_SomeClass: Cuckoo.StubbingProxy {
        private let cuckoo_manager: Cuckoo.MockManager
    
         init(manager: Cuckoo.MockManager) {
            self.cuckoo_manager = manager
        }
        
        
        
        
        func someMethod<M1: Cuckoo.Matchable>(_ parameter0: M1) -> Cuckoo.ClassStubNoReturnThrowingFunction<(some UIViewRepresentable)> where M1.MatchedType == some UIViewRepresentable {
            let matchers: [Cuckoo.ParameterMatcher<(some UIViewRepresentable)>] = [wrap(matchable: parameter0) { $0 }]
            return .init(stub: cuckoo_manager.createStub(for: MockSomeClass.self, method:
    """
    someMethod(_: some UIViewRepresentable) throws
    """, parameterMatchers: matchers))
        }
        
        
    }

and

 class MockSomeClass: SomeClass, Cuckoo.ClassMock {
    
     typealias MocksType = SomeClass
    
     typealias Stubbing = __StubbingProxy_SomeClass
     typealias Verification = __VerificationProxy_SomeClass

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

    
    private var __defaultImplStub: SomeClass?

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

    

    

    
    
    
    
     override func someMethod(_ parameter0: some UIViewRepresentable) throws {
        
    return try cuckoo_manager.callThrows(
    """
    someMethod(_: some UIViewRepresentable) throws
    """,
            parameters: (parameter0),
            escapingParameters: (parameter0),
            superclassCall:
                
                super.someMethod(parameter0)
                ,
            defaultCall: __defaultImplStub!.someMethod(parameter0))
        
    }
    
    

     struct __StubbingProxy_SomeClass: Cuckoo.StubbingProxy {
        private let cuckoo_manager: Cuckoo.MockManager
    
         init(manager: Cuckoo.MockManager) {
            self.cuckoo_manager = manager
        }
        
        
        func someMethod<M1: Cuckoo.Matchable>(_ parameter0: M1) -> Cuckoo.ClassStubNoReturnThrowingFunction<(some UIViewRepresentable)> where M1.MatchedType == some UIViewRepresentable {
            let matchers: [Cuckoo.ParameterMatcher<(some UIViewRepresentable)>] = [wrap(matchable: parameter0) { $0 }]
            return .init(stub: cuckoo_manager.createStub(for: MockSomeClass.self, method:
    """
    someMethod(_: some UIViewRepresentable) throws
    """, parameterMatchers: matchers))
        }
        
        
    }

     struct __VerificationProxy_SomeClass: 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
        }
    
        @discardableResult
        func someMethod<M1: Cuckoo.Matchable>(_ parameter0: M1) -> Cuckoo.__DoNotUse<(some UIViewRepresentable), Void> where M1.MatchedType == some UIViewRepresentable {
            let matchers: [Cuckoo.ParameterMatcher<(some UIViewRepresentable)>] = [wrap(matchable: parameter0) { $0 }]
            return cuckoo_manager.verify(
    """
    someMethod(_: some UIViewRepresentable) throws
    """, callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
        }
        
        
    }
}

and throws 'some' types are only permitted in properties, subscripts, and functions like the screenshot I attached below:
image

Could you check it once?

@enebin enebin changed the title Throwing 'some' types are only permitted in properties, subscripts, and functions when func throws & has some for its parameter Throwing "'some' types are only permitted in properties, subscripts, and functions" when func throws & has some for its parameter Jun 10, 2023
@MatyasKriz
Copy link
Collaborator

Hey there, @enebin! Thanks for bringing this to light. I'd like to improve the way Cuckoo works with types altogether, so it helps knowing of this case I need to think about. 🙂

@MatyasKriz MatyasKriz added the bug label Jun 12, 2023
@MatyasKriz
Copy link
Collaborator

I admit that I completely forgot about this case, but it seems like a good addition to the project. If you're willing to contribute, I'd gladly merge it! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants