Skip to content

proposal: ignore interfaces that contains type constraints#93

Merged
sywhang merged 4 commits intouber-go:mainfrom
hoonmin:feature/ignore-constraint-interfaces
Sep 25, 2023
Merged

proposal: ignore interfaces that contains type constraints#93
sywhang merged 4 commits intouber-go:mainfrom
hoonmin:feature/ignore-constraint-interfaces

Conversation

@hoonmin
Copy link
Copy Markdown
Contributor

@hoonmin hoonmin commented Sep 19, 2023

This is a proposal PR to generate mocks without error for following cases:

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.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Sep 19, 2023

CLA assistant check
All committers have signed the CLA.

@r-hang r-hang requested a review from JacobOaks September 19, 2023 18:21
Copy link
Copy Markdown
Contributor

@JacobOaks JacobOaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is good - just a couple comments. Thanks!

hoonmin and others added 2 commits September 24, 2023 23:50
Co-authored-by: Jacob Oaks <jacoboaks.8@gmail.com>
Co-authored-by: Jacob Oaks <jacoboaks.8@gmail.com>
@hoonmin
Copy link
Copy Markdown
Contributor Author

hoonmin commented Sep 24, 2023

I think this change is good - just a couple comments. Thanks!

I learned some basic but important things from your review. I've applied all of your suggestions, thank you!

Copy link
Copy Markdown
Contributor

@sywhang sywhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks for making this change!

@sywhang sywhang merged commit 7842e1d into uber-go:main Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants