Return the qualified name of the most qualified matching overload, or nullopt if no matches are found.
| 82 | // Return the qualified name of the most qualified matching overload, or |
| 83 | // nullopt if no matches are found. |
| 84 | absl::optional<std::string> BestOverloadMatch(const Resolver& resolver, |
| 85 | absl::string_view base_name, |
| 86 | int argument_count) { |
| 87 | if (IsSpecialFunction(base_name)) { |
| 88 | return std::string(base_name); |
| 89 | } |
| 90 | auto arguments_matcher = ArgumentsMatcher(argument_count); |
| 91 | // Check from most qualified to least qualified for a matching overload. |
| 92 | auto names = resolver.FullyQualifiedNames(base_name); |
| 93 | for (auto name = names.begin(); name != names.end(); ++name) { |
| 94 | if (OverloadExists(resolver, *name, arguments_matcher)) { |
| 95 | if (base_name[0] == '.') { |
| 96 | // Preserve leading '.' to prevent re-resolving at plan time. |
| 97 | return std::string(base_name); |
| 98 | } |
| 99 | return *name; |
| 100 | } |
| 101 | } |
| 102 | return absl::nullopt; |
| 103 | } |
| 104 | |
| 105 | // Rewriter visitor for resolving references. |
| 106 | // |
no test coverage detected