Closed Bug 1659520 Opened 5 years ago Closed 5 years ago

Use explicit type arguments for `SyncedContext` field setters

Categories

(Core :: DOM: Navigation, task, P3)

task

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: nika, Assigned: nika)

Details

Attachments

(1 file)

It is currently possible to accidentally declare easy-to-misuse overloads of the generated setter methods from the synced context macros.

// The generated declarations look like
template <typename T>
nsresult SetFoo(T&& aValue);
// Making it possible to declare an buggy overload like
nsresult SetFoo(bool aFoo);

This can be bad, especially if the overload has different behaviour, as calls with types which are implicitly convertable to bool may actually call the generated method, rather than the explicit overload.

This has already happened once in the form of SetAllowContentRetargeting, which is both generated from the macro here: https://searchfox.org/mozilla-central/rev/fa7f47027917a186fb2052dee104cd06c21dd76f/docshell/base/BrowsingContext.h#119, and overloaded here: https://searchfox.org/mozilla-central/rev/fa7f47027917a186fb2052dee104cd06c21dd76f/docshell/base/BrowsingContext.h#465

Type: defect → task
Severity: -- → N/A
Priority: -- → P3
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a31a710e76e4 Use explicit type arguments for `SyncedContext` field setters, r=farre
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: