 core/lib/Drupal/Core/Render/BubbleableMetadata.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/lib/Drupal/Core/Render/BubbleableMetadata.php b/core/lib/Drupal/Core/Render/BubbleableMetadata.php
index bed247a..1f23288 100644
--- a/core/lib/Drupal/Core/Render/BubbleableMetadata.php
+++ b/core/lib/Drupal/Core/Render/BubbleableMetadata.php
@@ -47,8 +47,10 @@ class BubbleableMetadata extends CacheableMetadata {
    */
   public function merge(CacheableMetadata $other) {
     $result = parent::merge($other);
-    $result->attached = \Drupal::service('renderer')->mergeAttachments($this->attached, $other->attached);
-    $result->postRenderCache = NestedArray::mergeDeep($this->postRenderCache, $other->postRenderCache);
+    if ($other instanceof BubbleableMetadata) {
+      $result->attached = \Drupal::service('renderer')->mergeAttachments($this->attached, $other->attached);
+      $result->postRenderCache = NestedArray::mergeDeep($this->postRenderCache, $other->postRenderCache);
+    }
     return $result;
   }
 
