[webkit-dev] 'final' class specifier and 'final' method specifier

Fujii Hironori fujii.hironori at gmail.com
Wed Dec 19 01:52:16 PST 2018

Hi WebKit devs,

'final' keyword can be applied to both a class and a method
(non-static member function). I don't know correct terminology for
them. I call them 'final' class specifier and 'final' method

I'm now going to update WebKit Code Style Guidelines for using 'final'
class specifier for all classes which has no derived classes in Bug

I believe this is not controversial. This is not a topic I'd like to
discuss today.

I'd like to discuss which 'override' or 'final' should be used for methods.

Currently, WebKit is using both inconsistently.
For example, CSSFontFaceSet class is marked 'final' and its methods are
marked 'final',
while CSSFontFaceSource class is marked 'final' and its methods are marked

According to WebKit Code Style Guidelines, 'final' method specifier is
preferable to 'override' if possible. There is a previous discussion

I'd like to change this because 'final' doesn't necessarily imply
'override'. See the following stackoverflow:

IIUC, 'final' method specifier can be useful for such like the following

class B {
  virtual foo();
  virtual bar();
class B1 : public B {
  foo() final;
class D final : B1 {
  bar() override;

The 'final' method specifier indicates D can't override the method foo.
Thus, using 'final' method specifier implies other virtual functions
can be overridden. I'm not sure my understanding right. Please correct me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20181219/48c7bcc9/attachment.html>

More information about the webkit-dev mailing list