| 108 | |
| 109 | template <typename Overload> |
| 110 | void AddOverloadInternal(std::string_view function_name, |
| 111 | std::vector<OverloadDecl>& insertion_order, |
| 112 | OverloadDeclHashSet& overloads, Overload&& overload, |
| 113 | absl::Status& status) { |
| 114 | if (!status.ok()) { |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | if (overload.id().empty()) { |
| 119 | OverloadDecl overload_decl = overload; |
| 120 | absl::StatusOr<std::string> overload_id = |
| 121 | common_internal::MakeOverloadSignature( |
| 122 | function_name, overload_decl.args(), overload_decl.member()); |
| 123 | if (!overload_id.ok()) { |
| 124 | status = overload_id.status(); |
| 125 | return; |
| 126 | } |
| 127 | overload_decl.set_id(*overload_id); |
| 128 | AddOverloadInternal(function_name, insertion_order, overloads, |
| 129 | std::move(overload_decl), status); |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | if (auto it = overloads.find(overload.id()); it != overloads.end()) { |
| 134 | status = absl::AlreadyExistsError( |
| 135 | absl::StrCat("overload already exists: ", overload.id())); |
| 136 | return; |
| 137 | } |
| 138 | for (const auto& existing : overloads) { |
| 139 | if (SignaturesOverlap(overload, existing)) { |
| 140 | status = absl::InvalidArgumentError( |
| 141 | absl::StrCat("overload signature collision: ", existing.id(), |
| 142 | " collides with ", overload.id())); |
| 143 | return; |
| 144 | } |
| 145 | } |
| 146 | const auto inserted = overloads.insert(std::forward<Overload>(overload)); |
| 147 | ABSL_DCHECK(inserted.second); |
| 148 | insertion_order.push_back(*inserted.first); |
| 149 | } |
| 150 | |
| 151 | void CollectTypeParams(absl::flat_hash_set<std::string>& type_params, |
| 152 | const Type& type) { |
no test coverage detected