docs: def clear_optimizer(self):
          """Cleans query optimizer state"""
          self._optimized = False
          self._type2decls = {}
          self._type2name2decls = {}
          self._type2decls_nr = {}
          self._type2name2decls_nr = {}
          self._all_decls = None
          self._all_decls_not_recursive = None
  
          for decl in self.declarations:
              if isinstance(decl, scopedef_t):
                  decl.clear_optimizer()