Make JSLinearString::ensureLinear (mutatis mutandis for JSFlatString and other subtypes, and for is* and as* methods) a compile error

RESOLVED FIXED in mozilla11

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Waldo, Assigned: Waldo)

Tracking

Trunk
mozilla11
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Created attachment 573001 [details] [diff] [review]
Patch

It's perfectly legal to call ensureLinear on a linear string right now.  It's also completely pointless.  We can make it a compile error so that this can't be done.  This sort of mistake is most likely to bite changes that improve typing of a class member (say, from JSString to JSLinearString), although I could imagine it happening if someone suffered a brief memory lapse when writing some other patch.
Attachment #573001 - Flags: review?(luke)

Updated

6 years ago
Attachment #573001 - Flags: review?(luke) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/85f790b1de47

Earlier this year C++11 had a declaration modifier, "new", which could be used to require that a declarator in a class hide an identically-typed declarator in a superclass.  It got taken out because the ISO people were running out of places to shoehorn it, for non-method declarator syntax.  Le sigh; that would have been perfect for these uses.

http://stackoverflow.com/questions/5530022/override-non-virtual-functions-in-c-2011

Oh well, this will likely work well enough.
Target Milestone: --- → mozilla11
https://hg.mozilla.org/mozilla-central/rev/85f790b1de47
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.