Bug 210775

Summary: Classes marked final should not use protected access specifier
Product: WebKit Reporter: Ross Kirsling <ross.kirsling>
Component: New BugsAssignee: Ross Kirsling <ross.kirsling>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, apinheiro, calvaris, cdumez, cfleizach, cmarcelo, darin, dino, dmazzoni, dstockwell, eric.carlson, esprehn+autocc, ews-watchlist, fmalita, fred.wang, glenn, graouts, gyuyoung.kim, hi, hta, jamesr, japhet, jcraig, jdiggs, jer.noble, jfernandez, joepeck, keith_miller, kondapallykalyan, luiz, macpherson, mark.lam, menard, mifenton, msaboff, pdr, philipj, rego, saam, sabouhallawa, samuel_white, schenney, sergio, simon.fraser, svillar, tommyw, tonikitoo, toyoshim, tzagallo, webkit-bug-importer, yutak
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Ross Kirsling 2020-04-20 17:08:20 PDT
Classes marked final should not use protected access specifier
Comment 1 Ross Kirsling 2020-04-20 17:09:18 PDT
Created attachment 397040 [details]
Patch
Comment 2 Ross Kirsling 2020-04-20 17:22:46 PDT
Created attachment 397041 [details]
Patch
Comment 3 Joseph Pecoraro 2020-04-20 17:45:24 PDT
The code movement in this patch presents a lot of noise that will make it more difficult to blame / investigate history. Is the movement worth it?
Comment 4 Ross Kirsling 2020-04-20 17:59:50 PDT
Created attachment 397043 [details]
Patch
Comment 5 Ross Kirsling 2020-04-20 18:05:54 PDT
(In reply to Joseph Pecoraro from comment #3)
> The code movement in this patch presents a lot of noise that will make it
> more difficult to blame / investigate history. Is the movement worth it?

I'd started with just JSC and figured it'd be beneficial to keep things consistently ordered (at least with, say, constructors and finishCreation) as well as to remove any public/private back-and-forth where trivial.

I applied that idea to other areas of the codebase too; the WebCore cases might be more questionable but I think the WKL/win cases are pretty nice.

Anyway you're free to object, but I feel like constructor declarations would be comparatively rare lines to blame?
Comment 6 Darin Adler 2020-04-20 18:07:39 PDT
Comment on attachment 397040 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=397040&action=review

> Source/JavaScriptCore/ChangeLog:3
> +        Classes marked final should not use protected access specifier

Great rule of thumb! I would say the same about *any* classes that have no classes derived from them, even if they aren’t marked final.

> Source/JavaScriptCore/runtime/Structure.h:-176
> -public:

This says "public", not "private"!!!
Comment 7 Darin Adler 2020-04-20 18:07:52 PDT Comment hidden (obsolete)
Comment 8 Darin Adler 2020-04-20 18:08:01 PDT Comment hidden (obsolete)
Comment 9 Darin Adler 2020-04-20 18:09:01 PDT
I think a little bit of code movements is worth it for clarity.
Comment 10 Ross Kirsling 2020-04-20 18:17:12 PDT
(In reply to Darin Adler from comment #6)
> Comment on attachment 397040 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=397040&action=review
> 
> > Source/JavaScriptCore/ChangeLog:3
> > +        Classes marked final should not use protected access specifier
> 
> Great rule of thumb! I would say the same about *any* classes that have no
> classes derived from them, even if they aren’t marked final.

Indeed -- Yusuke pointed out that JSC even has optimizations that can apply to classes marked final, though for this patch I'm not sure I want to go through all the protected-without-final cases, haha.

> > Source/JavaScriptCore/runtime/Structure.h:-176
> > -public:
> 
> This says "public", not "private"!!!

Yeah, it seems I was moving a bit too quickly on a few of these. 😅
Comment 11 Ross Kirsling 2020-04-20 19:16:01 PDT
Created attachment 397046 [details]
Patch
Comment 12 Daniel Bates 2020-04-20 22:39:22 PDT
Comment on attachment 397046 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=397046&action=review

Patch looks good.
Comment 13 Ross Kirsling 2020-04-20 22:44:04 PDT
Comment on attachment 397046 [details]
Patch

(In reply to Daniel Bates from comment #12)
> Comment on attachment 397046 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=397046&action=review
> 
> Patch looks good.

Thanks for the review!
Comment 14 EWS 2020-04-20 23:11:13 PDT
Committed r260415: <https://trac.webkit.org/changeset/260415>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397046 [details].
Comment 15 Radar WebKit Bug Importer 2020-04-20 23:12:17 PDT
<rdar://problem/62092856>