qapi: Tighten check whether implicit object type already exists
authorMarkus Armbruster <armbru@redhat.com>
Fri, 15 Mar 2024 15:23:00 +0000 (16:23 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 24 Apr 2024 08:03:54 +0000 (10:03 +0200)
Entities with names starting with q_obj_ are implicit object types.
Therefore, QAPISchema._make_implicit_object_type()'s .lookup_entity()
can only return a QAPISchemaObjectType.  Assert that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240315152301.3621858-25-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: John Snow <jsnow@redhat.com>
scripts/qapi/schema.py

index e52930a48acc2bda65e33658bf8f9879100aee5d..a6180f93c60e9fd822e2494027837c9302aba4ae 100644 (file)
@@ -1297,8 +1297,9 @@ class QAPISchema:
             return None
         # See also QAPISchemaObjectTypeMember.describe()
         name = 'q_obj_%s-%s' % (name, role)
-        typ = self.lookup_entity(name, QAPISchemaObjectType)
+        typ = self.lookup_entity(name)
         if typ:
+            assert(isinstance(typ, QAPISchemaObjectType))
             # The implicit object type has multiple users.  This can
             # only be a duplicate definition, which will be flagged
             # later.