Skip to content

Commit

Permalink
[Go] Fix GenNativeUnionUnPack for imported union type. (google#7579)
Browse files Browse the repository at this point in the history
* Fix GenNativeUnionUnPack for imported union type.

* Update test results.

Co-authored-by: Derek Bailey <[email protected]>
  • Loading branch information
Gh0u1L5 and dbaileychess authored Nov 13, 2022
1 parent 7b038e3 commit 41d6903
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/idl_gen_go.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions tests/MyGame/Example/Any.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions tests/MyGame/Example/AnyAmbiguousAliases.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions tests/MyGame/Example/AnyUniqueAliases.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 41d6903

Please sign in to comment.