mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 22:03:40 +00:00
make unions with type aliases more usable (#5019)
Some generic C++ and Rust code is not generated when unions use type aliases because of potential ambiguity. Actually check for this ambiguity and only disable offending code only if it is found.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
4c3b6c247d
commit
91fe9ba93f
@@ -327,7 +327,7 @@ struct EnumVal {
|
||||
};
|
||||
|
||||
struct EnumDef : public Definition {
|
||||
EnumDef() : is_union(false), uses_type_aliases(false) {}
|
||||
EnumDef() : is_union(false), uses_multiple_type_instances(false) {}
|
||||
|
||||
EnumVal *ReverseLookup(int64_t enum_idx, bool skip_union_default = true) {
|
||||
for (auto it = vals.vec.begin() +
|
||||
@@ -342,7 +342,9 @@ struct EnumDef : public Definition {
|
||||
|
||||
SymbolTable<EnumVal> vals;
|
||||
bool is_union;
|
||||
bool uses_type_aliases;
|
||||
// Type is a union which uses type aliases where at least one type is
|
||||
// available under two different names.
|
||||
bool uses_multiple_type_instances;
|
||||
Type underlying_type;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user