-
Notifications
You must be signed in to change notification settings - Fork 607
Nested interfaces with Generics #643
Comments
@bradleygore note as written this would not work ever since generics can only be used in source mode currently, reflection is not supported. |
Hey @codyoss - so are you saying that if I ran it as |
@bradleygore it does not, but just wanted to be clear with expectations that reflect mode will never work with generics.(At least for the foreseeable future) |
Ah, ok - I see. Thanks for the explanation 😄 |
Hey @codyoss - my team and I love There is a bot on it stating I need to sign a I really hope this is helpful, and am looking forward to feedback! Thank you! |
+1 for fixing this please 🙏 |
Actual behavior
Typing for nested generic interface is scoped to package the interface belongs to and not the pkgs the type belongs to.
Here is a complete example: https://github.com/bradleygore/gomock-generics-issue/blob/master/workers/custom.go
I pulled down
gomock
repo into~/git/gomock
and checked outmaster
and didcd mockgen && go install ./...
to install it.I then updated the
go.mod
to path to that resource:I then ran the cmd to generate mocks against the dev branch:
This did not produce any error, but it did produce an issue in the output:
Expected behavior
Expected behavior would be that the type for the generic parameter is not presumed to come from the same pkg as the generic interface's definition, as this causes the mock to not compile.
In this specific scenario, the mock would import
workers
pkg, and the output of the above would look like this:Additional Information
My primary use-case for this is a
Repository
style setup. Consider:Notes for the Maintainers
🎉 Y'all are awesome and
gomock
is fantastic! 🎉The text was updated successfully, but these errors were encountered: