gowrap icon indicating copy to clipboard operation
gowrap copied to clipboard

Support of union and type approximation in generics

Open zcolleen opened this issue 1 year ago • 0 comments

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.

zcolleen avatar Apr 28 '24 20:04 zcolleen