def _set_visible_scopes_for_type_definition(type_definition, visible_scopes):
  """Sets current_scope and visible_scopes for the given type_definition."""
  return {
      "current_scope": type_definition.name.canonical_name,

      # In order to ensure that the iteration through scopes in
      # _find_target_of_reference will go from innermost to outermost, it is
      # important that the current scope (type_definition.name.canonical_name)
      # precedes the previous visible_scopes here.
      "visible_scopes": (type_definition.name.canonical_name,) + visible_scopes,
  }