-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proposal: ignore interfaces that contains type constraints (#93)
This is a proposal PR to generate mocks without error for following cases: ```go type Water[R any, C UnsignedInteger] interface { Fish(R) []C } type UnsignedInteger interface { ~uint | ~uint32 | ~uint64 } ``` Go `types` package seems to wrap interfaces that contain type constraints by checking a type set literal of the form `~T` and `A|B`. https://github.com/golang/go/blob/master/src/go/types/decl.go#L668 So gomock can just ignore that pattern to generate mocks safely without `don't know how to mock method of type` errors. I think this can be a better solution for custom type constraints than [`-exclude` flag](#72). --------- Co-authored-by: Jacob Oaks <[email protected]>
- Loading branch information
Showing
4 changed files
with
67 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 42 additions & 24 deletions
66
mockgen/internal/tests/generics/source/mock_generics_mock.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters