| 239 | } |
| 240 | |
| 241 | bool FunctionRegistry::ValidateNonStrictOverload( |
| 242 | const cel::FunctionDescriptor& descriptor) const { |
| 243 | auto overloads = functions_.find(descriptor.name()); |
| 244 | if (overloads == functions_.end()) { |
| 245 | return true; |
| 246 | } |
| 247 | const RegistryEntry& entry = overloads->second; |
| 248 | if (!descriptor.is_strict()) { |
| 249 | // If the newly added overload is a non-strict function, we require that |
| 250 | // there are no other overloads, which is not possible here. |
| 251 | return false; |
| 252 | } |
| 253 | // If the newly added overload is a strict function, we need to make sure |
| 254 | // that no previous overloads are registered non-strict. If the list of |
| 255 | // overload is not empty, we only need to check the first overload. This is |
| 256 | // because if the first overload is strict, other overloads must also be |
| 257 | // strict by the rule. |
| 258 | return (entry.static_overloads.empty() || |
| 259 | entry.static_overloads[0].descriptor->is_strict()) && |
| 260 | (entry.lazy_overloads.empty() || |
| 261 | entry.lazy_overloads[0].descriptor->is_strict()); |
| 262 | } |
| 263 | |
| 264 | } // namespace cel |