Skip to content

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

@enebin

Description

@enebin

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions