diff --git a/tests/generic_relations_regress/models.py b/tests/generic_relations_regress/models.py
index 331c575..59b7215 100644
--- a/tests/generic_relations_regress/models.py
+++ b/tests/generic_relations_regress/models.py
@@ -215,3 +215,17 @@ def prevent_deletes(sender, instance, **kwargs):
     raise ProtectedError("Not allowed to delete.", [instance])
 
 models.signals.pre_delete.connect(prevent_deletes, sender=Node)
+
+
+class OtherSuper(models.Model):
+    pass
+
+
+class OtherSub(OtherSuper):
+    pass
+
+
+class Ref(models.Model):
+    obj_type = models.ForeignKey(ContentType, on_delete=models.PROTECT)
+    obj_id = models.CharField(max_length=255)
+    obj = GenericForeignKey('obj_type', 'obj_id')
diff --git a/tests/generic_relations_regress/tests.py b/tests/generic_relations_regress/tests.py
index 2c5b13d..ff8d3b0 100644
--- a/tests/generic_relations_regress/tests.py
+++ b/tests/generic_relations_regress/tests.py
@@ -276,3 +276,20 @@ class GenericRelationTests(TestCase):
     def test_ticket_22982(self):
         place = Place.objects.create(name='My Place')
         self.assertIn('GenericRelatedObjectManager', str(place.links))
+
+    def test_identity(self):
+        from .models import OtherSub, OtherSuper, Ref
+
+        for other_model in (OtherSuper, OtherSub):
+            with self.subTest(
+                other_model=other_model.__name__,
+            ):
+                other = other_model.objects.create()
+                ref = Ref.objects.create(obj=other)
+                # Get a fresh instance to test code that would be fetching an
+                # existing one.
+                ref.refresh_from_db()
+                self.assertEqual(
+                    id(ref.obj),
+                    id(ref.obj),
+                )
