Don't allow writes to inner objects through immutable properties
Summary:
If you have a mutable object embedded in an immutable property of another object, you can grab the inner, mutable object into a local and write to it. This changes the 'var_dump' view of the immutable property, but it is legal because immutability is shallow.
I initially thought that it would be useful to support writing to the inner, mutable object's properties using multi-level dims that pass through an immutable property. However, I only got it working if the mutable object was directly embedded in the immutable one, not if there was an array that had to be dimmed through in between (because that would have required keeping track of state that we didn't/don't track).
We had a design meeting to discuss if we wanted this behavior at all, and decided it was confusing, and we should never allow any writes that dim through an immutable property, even if you can accomplish the same thing by grabbing the inner, mutable object into a local and doing the same write via the local.
Remove the special case for dimming from an object into another object, and add a unit test.
Reviewed By: paulbiss
Differential Revision:
D7581144
fbshipit-source-id:
b047f014cbf89e03d18ada2077f2e5955bd48a4f