-
Notifications
You must be signed in to change notification settings - Fork 121
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
Interfaces that are type aliases are ignored #197
Comments
Here is a minimal reproducible form
It generates invalid go code func (m *MockA) A(arg0 compliance.T[go.uber.org/mock/gomock.Call]) compliance.T[go.uber.org/mock/gomock.Call] {
|
Line 420 in 857e269
This is a problematic line. As aliases are "invisible" during runtime in reflect mode we get an underlying type instead of alias this results in fully qualified path in the generic. This may be solved if we store all imports for a type and then sanitize type https://github.com/golang/proposal/blob/master/design/18130-type-alias.md#reflect |
I think the fix in reflect mode is via the new API, see #186 (comment). I'm using source mode, presumably the fix is different. |
Same issue with grpc stream interface (which is generic now). This is a blocking issue failing tests in CI. |
It worked for me in source mode on generated from .proto file grpc streaming inetrface |
Hi, I'm not sure if this issue is actually resolved. When using gomock v0.5.0 in source mode, type aliases is still ignored. I believe the fix #207 doesn't apply for source mode |
Actual behavior
I'm trying to generate a mock for a type that is a type alias for a generic interface. This is new functionality in gRPC (grpc/grpc-go#7030), available in protoc-gen-go-grpc v1.5.0.
Before v1.5.0 the type looks like this (works fine with source and reflect modes):
v1.5.1 generates the following:
gRPC type looks like this:
mockgen just ignores the type as if it's not in the file.
I've also tried to add a replacement type like this:
The above produces an error (I couldn't fix it with
-aux_files
):If I use the gRPC's interface explicitly, it works fine:
Expected behavior
I expect the generated alias
GitLabFlux_ReconcileProjectsClient
interface to generate a mock. I generate mocks for all gRPC-generated interfaces but this one (and similar ones) is skipped so I have to work this around, which is annoying.To Reproduce
Use a type alias and try to generate a mock for it.
Additional Information
Triage Notes for the Maintainers
The text was updated successfully, but these errors were encountered: