Make converting constructors from raw ref-counted objects be explicit
Summary: The constructors for Variant, String, Object, and Resource which take a raw
[String,Object,Resource]Data pointer manipulate the reference count as part of
the conversion. Since these constructors are implicit, that means you might be
undergoing reference count manipulations without realizing it. This is
especially problematic now that the ref-counts of all objects begin at 1, and
its important not to inc-ref again when wrapping the object. IE: its very easy
to make a mistake like this:
String func() {
return StringData::Make(...);
}
and end-up with a String with a ref-count of 2 instead of 1.
Therefore, its safer to make these constructors explicit. They still have the
same behavior, but at least you won't have such conversions happening unless you
explicitly ask for it.
Reviewed By: @edwinsmith
Differential Revision:
D2230166