diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php
index 594f31d..08f1e0a 100644
--- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php
+++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php
@@ -723,4 +723,19 @@ public function getConfig($bundle) {
     return BaseFieldOverride::createFromBaseFieldDefinition($this, $bundle);
   }
 
+  /**
+   * Magic method: Implements a deep clone.
+   */
+  public function __clone() {
+    // Ensure the itemDefinition property is actually cloned
+    // by overwriting the original reference.
+    $this->itemDefinition = clone $this->itemDefinition;
+
+    // The itemDefinition (\Drupal\Core\Field\TypedData\FieldItemDataDefinition)
+    // has a property fieldDefinition, which is a recursive reference to the
+    // parent BaseFieldDefinition. Need to overwrite the reference to the old
+    // object with a reference to the cloned one.
+    $this->itemDefinition->setFieldDefinition($this);
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php b/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php
index 4a6d877..2cd755b 100644
--- a/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php
+++ b/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php
@@ -83,4 +83,17 @@ public function getFieldDefinition() {
     return $this->fieldDefinition;
   }
 
+  /**
+   * Sets the field item's field definition.
+   *
+   * @param \Drupal\Core\Field\FieldDefinitionInterface
+   *
+   * @return static
+   *   The object itself for chaining.
+   */
+  public function setFieldDefinition($field_definition) {
+    $this->fieldDefinition = $field_definition;
+    return $this;
+  }
+
 }
diff --git a/core/modules/comment/tests/src/Kernel/CommentBundlesTest.php b/core/modules/comment/tests/src/Kernel/CommentBundlesTest.php
new file mode 100644
index 0000000..d907233
--- /dev/null
+++ b/core/modules/comment/tests/src/Kernel/CommentBundlesTest.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Drupal\Tests\comment\Kernel;
+
+use Drupal\comment\Entity\CommentType;
+use Drupal\KernelTests\KernelTestBase;
+
+/**
+ * Tests that comment bundles behave as expected.
+ *
+ * @group comment
+ */
+class CommentBundlesTest extends KernelTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['comment', 'node', 'taxonomy', 'user'];
+
+  /**
+   * Entity type ids to use for target_entity_type_id on comment bundles.
+   *
+   * @var array
+   */
+  protected $targetEntityTypes;
+
+  /**
+   * @var \Drupal\Core\Entity\EntityFieldManagerInterface
+   */
+  protected $entityFieldManager;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->entityFieldManager = $this->container->get('entity_field.manager');
+
+    $this->installEntitySchema('comment');
+
+    // Create multiple comment bundles,
+    // each of which has a different target entity type.
+    $this->targetEntityTypes = [
+      'comment' => 'Comment',
+      'node' => 'Node',
+      'taxonomy_term' => 'Taxonomy Term',
+    ];
+    foreach ($this->targetEntityTypes as $id => $label) {
+      CommentType::create([
+        'id' => 'comment_on_' . $id,
+        'label' => 'Comment on ' . $label,
+        'target_entity_type_id' => $id,
+      ])->save();
+    }
+  }
+
+  /**
+   * Test that the entity_id field is set correctly for each comment bundle.
+   */
+  public function testEntityIdField() {
+    $field_definitions = [];
+
+    foreach (array_keys($this->targetEntityTypes) as $id) {
+      $bundle = 'comment_on_' . $id;
+      $field_definitions[$bundle] = $this->entityFieldManager
+        ->getFieldDefinitions('comment', $bundle);
+    }
+    // Test that the value of the entity_id field for each bundle is correct.
+    foreach ($field_definitions as $bundle => $definition) {
+      $entity_type_id = str_replace('comment_on_', '', $bundle);
+      $target_type = $definition['entity_id']->getSetting('target_type');
+      $this->assertEquals($entity_type_id, $target_type);
+
+      // Verify that the target type remains correct
+      // in the deeply-nested object properties.
+      $nested_target_type = $definition['entity_id']->getItemDefinition()->getFieldDefinition()->getSetting('target_type');
+      $this->assertEquals($entity_type_id, $nested_target_type);
+    }
+
+  }
+
+}
