[Go] Fix GenNativeUnionUnPack for imported union type. (#7579)

* Fix GenNativeUnionUnPack for imported union type.

* Update test results.

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Gh0u1L5
2022-11-14 03:52:02 +08:00
committed by GitHub
parent 7b038e3277
commit 41d6903294
4 changed files with 22 additions and 10 deletions

View File

@@ -906,7 +906,10 @@ class GoGenerator : public BaseGenerator {
const EnumVal &ev = **it2;
if (ev.IsZero()) continue;
code += "\tcase " + namer_.EnumVariant(enum_def, ev) + ":\n";
code += "\t\tx := " + ev.union_type.struct_def->name + "{_tab: table}\n";
code += "\t\tvar x " +
WrapInNameSpaceAndTrack(*ev.union_type.struct_def) +
"\n";
code += "\t\tx.Init(table.Bytes, table.Pos)\n";
code += "\t\treturn &" +
WrapInNameSpaceAndTrack(enum_def.defined_namespace,