diff --git a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h index 61e616eff49..f87bc5051a5 100644 --- a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h +++ b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h @@ -77,6 +77,10 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { UnsharedShadowNode cloneShadowNode( const ShadowNode &sourceShadowNode, const ShadowNodeFragment &fragment) const override { + assert( + dynamic_cast(&sourceShadowNode) && + "Provided `sourceShadowNode` has an incompatible type."); + auto shadowNode = std::make_shared(sourceShadowNode, fragment); adopt(shadowNode); @@ -86,6 +90,10 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { void appendChild( const SharedShadowNode &parentShadowNode, const SharedShadowNode &childShadowNode) const override { + assert( + dynamic_cast(parentShadowNode.get()) && + "Provided `parentShadowNode` has an incompatible type."); + auto concreteParentShadowNode = std::static_pointer_cast(parentShadowNode); auto concreteNonConstParentShadowNode = @@ -96,6 +104,11 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { virtual SharedProps cloneProps( const SharedProps &props, const RawProps &rawProps) const override { + assert( + !props || + dynamic_cast(props.get()) && + "Provided `props` has an incompatible type."); + if (rawProps.isEmpty()) { return props ? props : ShadowNodeT::defaultSharedProps(); } @@ -132,6 +145,12 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { return nullptr; } + assert(previousState && "Provided `previousState` is nullptr."); + assert(data && "Provided `data` is nullptr."); + assert( + dynamic_cast(previousState.get()) && + "Provided `previousState` has an incompatible type."); + return std::make_shared( std::move(*std::static_pointer_cast(data)), *std::static_pointer_cast(previousState));