In the MutableList API, make an internal unsafe method public
This method acts as an "escape hatch" for mutating a list regardless of Mutability. It should be avoided if at all possible.
RELNOTES: None
@@ -335,8 +335,17 @@ public abstract class SkylarkList<E> extends BaseMutableList<E>
ImmutableList.copyOf(contents), env == null ? null : env.mutability());
}
- /** Appends the given elements to the end of the list, without calling {@link #checkMutable}. */
- private void addAllUnsafe(Iterable<? extends E> elements) {
+ /**
+ * Appends the given elements to the end of the list, without calling {@link #checkMutable}.
+ *
+ * <p><em>Warning:</em> This method should never be used by a caller that cares about respecting
+ * mutability restrictions. Such callers should instead use the safe {@link #addAll(Iterable,
+ * Location, Mutability)} method below. This unsafe variant is only public in order to provide
+ * an "escape hatch" for when ordinary mutability restrictions are inapplicable, e.g. for
+ * constructing lists from outside a Skylark environment and where it's impossible for multiple
+ * threads to observe the value at once.
+ */
+ public void addAllUnsafe(Iterable<? extends E> elements) {
Iterables.addAll(contents, elements);
}
