Brightify / Cuckoo

Boilerplate-free mocking framework for Swift!
MIT License
1.67k stars 174 forks source link

Generator v2: Generic Restrictions on Method missing #497

Closed alexdm-e2n closed 5 months ago

alexdm-e2n commented 5 months ago

A class with the following func is mocked.

class GraphQLClient {
  func fetch<Query: ApolloAPI.GraphQLQuery>(query: Query) async -> Result<Query.Data.Model, Error> { ... }
}

Cuckoo v2:

class MockGraphQLClient: GraphQLClient, Cuckoo.ClassMock {
  override func fetch<Query> (query p0: Query) async -> Result<Query.Data.Model, Error> { ...
  }
}

Issue: Mock cannot compile because of the missing protocol restriction <Query: ApolloAPI.GraphQLQuery>.

Cuckoo v1:

class MockGraphQLClient: GraphQLClient, Cuckoo.ClassMock {
  override func fetch<Query: ApolloAPI.GraphQLQuery>(query: Query) async -> Result<Query.Data.Model, Error> { ...
  }
}

I expected the code like v1. Am I missing a configuration option here or is this an issue?

MatyasKriz commented 5 months ago

This is definitely a bug, thank you for bringing it to light. 🙂

MatyasKriz commented 5 months ago

Should be fixed in version 2.0.5, please try it out and let me know if you find any other issues, thanks again!

alexdm-e2n commented 5 months ago

Thank you for your fast response. After clearing the full project it worked. Thank you! 👍