From 7163e4d4563455bd897f91aef6b618f07b5f45eb Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 10 Feb 2023 11:02:22 -0500 Subject: [PATCH] LibJS: Change ThrowableStringBuilder to privately inherit StringBuilder Not an issue currently, but while developing, it's easy to miss cases where an infallible AK::StringBuilder method is still used. By making this inheritance private, and explicitly pulling in base methods we can safely use, we get extra help from the compiler to indicate such mistakes immediately. --- Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h b/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h index 39d5e91054..a5958bf968 100644 --- a/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h +++ b/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h @@ -15,7 +15,7 @@ namespace JS { -class ThrowableStringBuilder : public AK::StringBuilder { +class ThrowableStringBuilder : private AK::StringBuilder { public: explicit ThrowableStringBuilder(VM&); @@ -25,6 +25,10 @@ public: ThrowCompletionOr append_code_point(u32 value); ThrowCompletionOr to_string() const; + using AK::StringBuilder::is_empty; + using AK::StringBuilder::string_view; + using AK::StringBuilder::trim; + private: VM& m_vm; };