mock icon indicating copy to clipboard operation
mock copied to clipboard

deprecated reflect mode has been replaced with import mode

Open tulzke opened this issue 1 year ago • 0 comments

resolves https://github.com/uber-go/mock/issues/175 resolves https://github.com/uber-go/mock/issues/197 resolves https://github.com/uber-go/mock/issues/128

It is impossible to create an mock for a generic interface via reflect mode, because it is impossible to compile a generic type without instantiation. This PR replaces the reflect mod for parsing using go/types.

All exists mocks have been regenerated and the tests have been passed. But since this radically changes the behavior of reflect mode, I would be grateful if there are those who want to add additional test cases that I did not provide.

We can also come up with another name instead of import mode.

benefits:

  • generation mocks for generic interfaces
  • generation mocks for aliases to interfaces
  • correct names for method arguments

tulzke avatar Aug 09 '24 11:08 tulzke