From 25239daeee96f68197f134cf07ad6fbf4549dc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= Date: Wed, 25 Sep 2024 10:28:29 +0200 Subject: [PATCH] fix(code-gen/go): fix issues on combined parent-child assignment too early --- .../resources/templates/go/complex-type-template.go.ftlh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh index fbdfb83f934..e729ca86d30 100644 --- a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh +++ b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh @@ -852,7 +852,9 @@ func ${type.name}ParseWithBuffer<#if type.isDiscriminatedParentTypeDefinition()> func (m *_${type.name}) parse(ctx context.Context, readBuffer utils.ReadBuffer<#if type.isDiscriminatedChildTypeDefinition()>, parent *_${type.getParentType().orElseThrow().name}<#if hasParserArguments>, ${parserArgumentList}) (__${type.name?uncap_first} ${type.name}, err error) { <#if type.isDiscriminatedChildTypeDefinition()> m.${type.getParentType().orElseThrow().name}Contract = parent - parent._SubType = m + <#if !type.isDiscriminatedParentTypeDefinition()> + parent._SubType = m + positionAware := readBuffer _ = positionAware @@ -1168,6 +1170,9 @@ func (m *_${type.name}) parse(ctx context.Context, readBuffer utils.ReadBuffer<# } <#if type.isDiscriminatedParentTypeDefinition()> + <#if type.isDiscriminatedChildTypeDefinition()> + parent._SubType = _child + return _child, nil <#else> return m, nil