mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-06-05 22:43:59 +00:00
6ab80c27e1
Optional fields whose type was a sealed-interface union without an auto-decode discriminator (BotCommandScope, InputMedia, InputPaidMedia, InputProfilePhoto, InputStoryContent, InputMessageContent, InputPollMedia, InputPollOptionMedia, InlineQueryResult, PassportElementError) were emitted as *<Union> — pointer to interface, which is a Go anti-pattern: interfaces are already nil-able, and callers were forced to take addresses of concrete variants. The codegen path goType() guarded against pointer-wrapping using knownDiscriminators (only 13 unions with auto-decode dispatch), missing the 10 marker-only sealed interfaces. New package var knownInterfaceTypes is built from buildUnionTypeSet at emitter construction and covers both kinds. goType() now consults that. Net effect: - api/methods.gen.go: 3 *BotCommandScope and 2 *InputPollMedia fields become bare interface - api/types.gen.go: 14 *InputMessageContent and 1 *InputPollOptionMedia fields become bare interface Regression tests in api/unionparam_test.go cover both shapes: direct concrete-variant assignment, and nil omitempty on the bare interface field.