File tree 2 files changed +26
-0
lines changed
main/java/com/facebook/react/uimanager
test/java/com/facebook/react/fabric
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,9 @@ protected ReactShadowNodeImpl copy() {
166
166
@ Override
167
167
public ReactShadowNodeImpl mutableCopy () {
168
168
ReactShadowNodeImpl copy = copy ();
169
+ Assertions .assertCondition (
170
+ getClass () == copy .getClass (),
171
+ "Copied shadow node must use the same class" );
169
172
if (mYogaNode != null ) {
170
173
copy .mYogaNode = mYogaNode .clone ();
171
174
copy .mYogaNode .setData (copy );
@@ -182,6 +185,9 @@ public ReactShadowNodeImpl mutableCopy() {
182
185
@ Override
183
186
public ReactShadowNodeImpl mutableCopyWithNewChildren () {
184
187
ReactShadowNodeImpl copy = copy ();
188
+ Assertions .assertCondition (
189
+ getClass () == copy .getClass (),
190
+ "Copied shadow node must use the same class" );
185
191
if (mYogaNode != null ) {
186
192
copy .mYogaNode = mYogaNode .cloneWithNewChildren ();
187
193
copy .mYogaNode .setData (copy );
Original file line number Diff line number Diff line change
1
+ // Copyright 2004-present Facebook. All Rights Reserved.
2
+ package com .facebook .react .fabric ;
3
+
4
+ import com .facebook .react .uimanager .ReactShadowNodeImpl ;
5
+ import com .facebook .testing .robolectric .v3 .WithTestDefaultsRunner ;
6
+ import org .junit .Test ;
7
+ import org .junit .runner .RunWith ;
8
+
9
+ /** Tests {@link ReactShadowNode} */
10
+ @ RunWith (WithTestDefaultsRunner .class )
11
+ public class ReactShadowNodeTest {
12
+
13
+ @ Test (expected = AssertionError .class )
14
+ public void testClonedInstance () {
15
+ TestReactShadowNode node = new TestReactShadowNode ();
16
+ node .mutableCopy ();
17
+ }
18
+
19
+ private static class TestReactShadowNode extends ReactShadowNodeImpl {}
20
+ }
You can’t perform that action at this time.
0 commit comments