1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +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:
Andreas Kling 2020-04-05 11:11:07 +02:00
parent 058c614110
commit 1d468ed6d3
11 changed files with 68 additions and 54 deletions

View file

@ -36,8 +36,8 @@ RefPtr<StyleDeclaration> parse_css_declaration(const StringView&);
NonnullRefPtr<StyleValue> parse_css_value(const StringView&);
Optional<Selector> parse_selector(const StringView&);
RefPtr<StyleValue> parse_line_width(const StringView&);
RefPtr<StyleValue> parse_color(const StringView&);
RefPtr<StyleValue> parse_line_style(const StringView&);
RefPtr<LengthStyleValue> parse_line_width(const StringView&);
RefPtr<ColorStyleValue> parse_color(const StringView&);
RefPtr<StringStyleValue> parse_line_style(const StringView&);
}