mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 18:19:03 +00:00
LibJS: Remove Object::is_array() in favor of Value::is_array() and RTTI
It's way too easy to get this wrong: for the IsArray abstract operation, Value::is_array() needs to be called. Since we have RTTI, the virtual Object::is_array() method is not needed anymore - if we need to know whether something is *actually* a JS::Array (we currently check in more cases than we should, I think) and not a Proxy with an Array target, we should do that in a way that doesn't look like an abstract operation.
This commit is contained in:
parent
06ffc0c4db
commit
0ba81dc0b7
Notes:
sideshowbarker
2024-07-18 10:18:06 +09:00
Author: https://github.com/linusg
Commit: 0ba81dc0b7
Pull-request: https://github.com/SerenityOS/serenity/pull/8468
8 changed files with 8 additions and 11 deletions
|
@ -203,7 +203,7 @@ bool Value::is_array(GlobalObject& global_object) const
|
|||
if (!is_object())
|
||||
return false;
|
||||
auto& object = as_object();
|
||||
if (object.is_array())
|
||||
if (is<Array>(object))
|
||||
return true;
|
||||
if (is<ProxyObject>(object)) {
|
||||
auto& proxy = static_cast<ProxyObject const&>(object);
|
||||
|
@ -219,7 +219,7 @@ bool Value::is_array(GlobalObject& global_object) const
|
|||
|
||||
Array& Value::as_array()
|
||||
{
|
||||
VERIFY(is_object() && as_object().is_array());
|
||||
VERIFY(is_object() && is<Array>(as_object()));
|
||||
return static_cast<Array&>(*m_value.as_object);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue