Fixes a bug where bools arent being nil when marked optional (#7051)

This commit is contained in:
mustiikhalil
2022-01-31 18:12:57 +03:00
committed by GitHub
parent 1d294a31b8
commit 4f3b24db09
2 changed files with 3 additions and 3 deletions

View File

@@ -711,8 +711,8 @@ class SwiftGenerator : public BaseGenerator {
}
if (IsBool(field.value.type.base_type)) {
std::string default_value =
"0" == field.value.constant ? "false" : "true";
std::string default_value = field.IsOptional() ? "nil" :
("0" == field.value.constant ? "false" : "true");
code_.SetValue("CONSTANT", default_value);
code_.SetValue("VALUETYPE", "Bool");
code_ += GenReaderMainBody(optional) + "\\";