hexdigest / gowrap

GoWrap is a command line tool for generating decorators for Go interfaces
MIT License
1.06k stars 82 forks source link

Support of union and type approximation in generics #86

Closed zcolleen closed 5 months ago

zcolleen commented 5 months ago

I discovered that in last version of minimock (v3.3.7) when we upped version of gowrap we broke generation of interfaces with generic unions. It happened because of this pr https://github.com/hexdigest/gowrap/pull/84 . So here i introduce support of generic types with union, e.g.

type genericInlineUnionWithManyTypes[T int | float64 | string] interface {
    Name(T)
}

and with type approximations , е.g.

type generic[T ~int] interface {
    Name(T)
}

and their combinations.

I also removed panic of unsupported generic type, because if we encounter unsupported generic type we should be able at least to finish generation without panicing.