-
Notifications
You must be signed in to change notification settings - Fork 607
feat: support embedded generic interfaces #669
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
@n0trace Thanks for the PR! Would you be willing to expand support for this test case as well:
If you don't have the time I can review this as is and this could be done in another PR. |
@n0trace Sorry if I was not clear, I meant just copy paste that code literally into generics.go. I don't think this solution covers the case where the outer interface does not contain type parameters, but the inner impl does. |
cases are complex than I have imagined, but done. please review. @codyoss |
fixes #658 |
@n0trace I will take a look over the weekend, thank you! |
As a heads up I verified this also fixes the same issue we were seeing in #658 |
Reviewing this today, sorry. Had gotten pulled away from this project for awhile! |
@n0trace I am still digging through the code, but would you mind adding some docs around the new types/fields/methods you added. I know parsing code is lacking this in general right now, but since this adds a bit of complexity it would be nice to have so details of what/how things are being used. |
I'm having the same issue and I'm hoping this fix could make it to official as soon as possible. |
I'm also having the same issue, could you please review this? |
This is needed, please review. Thanks! |
@codyoss we need a resolution for mock generics. please review. |
We are also blocked on this - would love if we could use this ❤️ |
Thanks for the pull request. Support for generics would be most welcome! Any update? |
I tested this PR with go version go1.20.1 linux/amd64 and can confirm generics are working. |
@codyoss or anyone else that can approve this PR. My team is really getting hamstrung and we're now starting to consider a different mocking library for go but then that'll be two testing standards which I do not want. Please get this approved! |
@codyoss Can you please have a look at this |
Also eagerly awaiting this. |
Just looked at Cody's LinkedIn profile. Looks like he got promoted and is no longer part of Google's Golang Developer Relations team. I think we should ping another person to get this PR merged. |
@n0trace hi, I get a error when mock the interface which embedded a another package's pointer and generic types ( test demo like below: package a
type ChildRepo interface {
b.Repo[*b.SomeStruct]
} package b
type Repo[T any] interface {
}
type SomeStruct struct {
} It will be ok when I use struct to instead of pointer type ChildRepo interface {
b.Repo[b.SomeStruct]
} |
@ShiningRush fixed it @codyoss I've refactored my implementation, and now it's easy to understand and maintain. I'd appreciate it if you could take some time to review it |
fixes #668 #658 #700