MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / BestOverloadMatch

Function BestOverloadMatch

eval/compiler/qualified_reference_resolver.cc:84–103  ·  view source on GitHub ↗

Return the qualified name of the most qualified matching overload, or nullopt if no matches are found.

Source from the content-addressed store, hash-verified

82// Return the qualified name of the most qualified matching overload, or
83// nullopt if no matches are found.
84absl::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//

Callers 1

MaybeUpdateCallNodeMethod · 0.85

Calls 6

IsSpecialFunctionFunction · 0.85
ArgumentsMatcherFunction · 0.85
OverloadExistsFunction · 0.85
FullyQualifiedNamesMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected