mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
AK: Stop allowing implicit downcast with RefPtr and NonnullRefPtr
We were allowing this dangerous kind of thing:
RefPtr<Base> base;
RefPtr<Derived> derived = base;
This patch changes the {Nonnull,}RefPtr constructors so this is no
longer possible.
To downcast one of these pointers, there is now static_ptr_cast<T>:
RefPtr<Derived> derived = static_ptr_cast<Derived>(base);
Fixing this exposed a ton of cowboy-downcasts in various places,
which we're now forced to fix. :^)
This commit is contained in:
@@ -32,10 +32,10 @@ namespace JS {
|
||||
|
||||
class ScriptFunction final : public Function {
|
||||
public:
|
||||
ScriptFunction(const ScopeNode& body, Vector<FlyString> parameters = {});
|
||||
ScriptFunction(const Statement& body, Vector<FlyString> parameters = {});
|
||||
virtual ~ScriptFunction();
|
||||
|
||||
const ScopeNode& body() const { return m_body; }
|
||||
const Statement& body() const { return m_body; }
|
||||
const Vector<FlyString>& parameters() const { return m_parameters; };
|
||||
|
||||
virtual Value call(Interpreter&) override;
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
static Value length_getter(Interpreter&);
|
||||
static void length_setter(Interpreter&, Value);
|
||||
|
||||
NonnullRefPtr<ScopeNode> m_body;
|
||||
NonnullRefPtr<Statement> m_body;
|
||||
const Vector<FlyString> m_parameters;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user