Fix some incorrect checks for Array property types

This commit is contained in:
Thomas Goyne 2017-08-29 14:56:12 -07:00
parent f5a940fd0c
commit 675b517274
1 changed files with 7 additions and 15 deletions

View File

@ -364,14 +364,10 @@ inline bool Value<T>::is_valid_for_property(ContextType context, const ValueType
} else if (prop.type == PropertyType::LinkingObjects) { } else if (prop.type == PropertyType::LinkingObjects) {
return false; return false;
} }
else if (prop.type == PropertyType::Array) {
return true;
}
return false; return false;
} }
using PropertyType = realm::PropertyType;
switch (prop.type & ~PropertyType::Flags) { switch (prop.type & ~PropertyType::Flags) {
case PropertyType::Int: case PropertyType::Int:
case PropertyType::Float: case PropertyType::Float:
@ -389,10 +385,9 @@ inline bool Value<T>::is_valid_for_property(ContextType context, const ValueType
return true; return true;
case PropertyType::Any: case PropertyType::Any:
return false; return false;
default:
REALM_UNREACHABLE();
} }
REALM_UNREACHABLE();
return false;
} }
inline std::string js_type_name_for_property_type(PropertyType type) inline std::string js_type_name_for_property_type(PropertyType type)
@ -401,12 +396,10 @@ inline std::string js_type_name_for_property_type(PropertyType type)
if (type == PropertyType::LinkingObjects) { if (type == PropertyType::LinkingObjects) {
throw std::runtime_error("LinkingObjects' type is not supported"); throw std::runtime_error("LinkingObjects' type is not supported");
} }
else if (type == PropertyType::Array) { return "array";
return "array";
}
} }
switch (type) { switch (type & ~PropertyType::Flags) {
case PropertyType::Int: case PropertyType::Int:
case PropertyType::Float: case PropertyType::Float:
case PropertyType::Double: case PropertyType::Double:
@ -423,10 +416,9 @@ inline std::string js_type_name_for_property_type(PropertyType type)
return "object"; return "object";
case PropertyType::Any: case PropertyType::Any:
throw std::runtime_error("'Any' type is not supported"); throw std::runtime_error("'Any' type is not supported");
default:
REALM_UNREACHABLE();
} }
REALM_UNREACHABLE();
return "<unknown>";
} }
} // js } // js