-
Notifications
You must be signed in to change notification settings - Fork 39
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
Unexpected behavior: embedded generic interface require their type arguments to be interfaces #113
Comments
Seems like the error originates here: var errNotAnInterface = errors.New("embedded type is not an interface")
func processIdent(i *ast.Ident, input targetProcessInput) (methodsList, error) {
var embeddedInterface *ast.InterfaceType
var genericsTypes genericTypes
for _, t := range input.types {
if t.Name.Name == i.Name {
var ok bool
embeddedInterface, ok = t.Type.(*ast.InterfaceType)
if !ok {
return nil, errors.Wrap(errNotAnInterface, t.Name.Name)
}
genericsTypes = buildGenericTypesFromSpec(t, input.types, input.typesPrefix)
break
}
}
if embeddedInterface == nil {
return nil, nil
}
input.genericTypes = genericsTypes
return processInterface(embeddedInterface, input)
} This also fails with the same error:
Maybe the parser thinks that Even in that case, since Go.18, arbitrary types can be embedded into interfaces (https://go.dev/ref/spec#Go_1.18):
Should I open an issue for gowrap? |
Also, using an interface as the type argument rather than the struct generates code, but it's not correct. The generated file has a bunch of references to E.g. in Seems like gowrap isn't handling embedded interfaces correctly. |
Hey @danvolchek thank for issue! Lets clarify few things. type Foo interface {
Bar[Baz]
} is a clear bug, i agree. The last point about |
When using this file:
The resulting error is:
Why does
Baz
need to be an interface? As a type parameter toBar
it doesn't matter what type it is - the generated code would be the same - right? Am I misunderstanding?Thanks!
The text was updated successfully, but these errors were encountered: