Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions checker/internal/descriptor_pool_type_introspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace {

// Standard implementation for field lookups.
// Avoids building a FieldTable and just checks the DescriptorPool directly.
absl::StatusOr<absl::optional<StructTypeField>>
absl::StatusOr<std::optional<StructTypeField>>
FindStructTypeFieldByNameDirectly(
const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
absl::string_view type, absl::string_view name) {
Expand All @@ -60,7 +60,7 @@ FindStructTypeFieldByNameDirectly(
// Standard implementation for listing fields.
// Avoids building a FieldTable and just checks the DescriptorPool directly.
absl::StatusOr<
absl::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
std::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
ListStructTypeFieldsDirectly(
const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
absl::string_view type) {
Expand Down Expand Up @@ -88,7 +88,7 @@ ListStructTypeFieldsDirectly(

using Field = DescriptorPoolTypeIntrospector::Field;

absl::StatusOr<absl::optional<Type>>
absl::StatusOr<std::optional<Type>>
DescriptorPoolTypeIntrospector::FindTypeImpl(absl::string_view name) const {
const google::protobuf::Descriptor* absl_nullable descriptor =
descriptor_pool_->FindMessageTypeByName(name);
Expand All @@ -103,7 +103,7 @@ DescriptorPoolTypeIntrospector::FindTypeImpl(absl::string_view name) const {
return absl::nullopt;
}

absl::StatusOr<absl::optional<TypeIntrospector::EnumConstant>>
absl::StatusOr<std::optional<TypeIntrospector::EnumConstant>>
DescriptorPoolTypeIntrospector::FindEnumConstantImpl(
absl::string_view type, absl::string_view value) const {
const google::protobuf::EnumDescriptor* absl_nullable enum_descriptor =
Expand All @@ -124,7 +124,7 @@ DescriptorPoolTypeIntrospector::FindEnumConstantImpl(
return absl::nullopt;
}

absl::StatusOr<absl::optional<StructTypeField>>
absl::StatusOr<std::optional<StructTypeField>>
DescriptorPoolTypeIntrospector::FindStructTypeFieldByNameImpl(
absl::string_view type, absl::string_view name) const {
if (!use_json_name_) {
Expand All @@ -151,7 +151,7 @@ DescriptorPoolTypeIntrospector::FindStructTypeFieldByNameImpl(
}

absl::StatusOr<
absl::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
std::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
DescriptorPoolTypeIntrospector::ListFieldsForStructTypeImpl(
absl::string_view type) const {
if (!use_json_name_) {
Expand Down
4 changes: 2 additions & 2 deletions checker/internal/descriptor_pool_type_introspector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST(DescriptorPoolTypeIntrospectorTest,
internal::GetTestingDescriptorPool());
introspector.set_use_json_name(true);

absl::StatusOr<absl::optional<StructTypeField>> field =
absl::StatusOr<std::optional<StructTypeField>> field =
introspector.FindStructTypeFieldByName(
"cel.expr.conformance.proto3.TestAllTypes", "singleInt64");

Expand All @@ -132,7 +132,7 @@ TEST(DescriptorPoolTypeIntrospectorTest, ListFieldsForStructType) {
DescriptorPoolTypeIntrospector introspector(
internal::GetTestingDescriptorPool());
absl::StatusOr<
absl::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
std::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
fields = introspector.ListFieldsForStructType(
"cel.expr.conformance.proto3.TestAllTypes");
ASSERT_THAT(fields, IsOkAndHolds(Optional(SizeIs(260))));
Expand Down
10 changes: 5 additions & 5 deletions checker/internal/type_check_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const FunctionDecl* absl_nullable TypeCheckEnv::LookupFunction(
return nullptr;
}

absl::StatusOr<absl::optional<Type>> TypeCheckEnv::LookupTypeName(
absl::StatusOr<std::optional<Type>> TypeCheckEnv::LookupTypeName(
absl::string_view name) const {
for (auto iter = type_providers_.begin(); iter != type_providers_.end();
++iter) {
Expand All @@ -60,7 +60,7 @@ absl::StatusOr<absl::optional<Type>> TypeCheckEnv::LookupTypeName(
return absl::nullopt;
}

absl::StatusOr<absl::optional<VariableDecl>> TypeCheckEnv::LookupEnumConstant(
absl::StatusOr<std::optional<VariableDecl>> TypeCheckEnv::LookupEnumConstant(
absl::string_view type, absl::string_view value) const {
for (auto iter = type_providers_.begin(); iter != type_providers_.end();
++iter) {
Expand All @@ -77,9 +77,9 @@ absl::StatusOr<absl::optional<VariableDecl>> TypeCheckEnv::LookupEnumConstant(
return absl::nullopt;
}

absl::StatusOr<absl::optional<VariableDecl>> TypeCheckEnv::LookupTypeConstant(
absl::StatusOr<std::optional<VariableDecl>> TypeCheckEnv::LookupTypeConstant(
google::protobuf::Arena* absl_nonnull arena, absl::string_view name) const {
CEL_ASSIGN_OR_RETURN(absl::optional<Type> type, LookupTypeName(name));
CEL_ASSIGN_OR_RETURN(std::optional<Type> type, LookupTypeName(name));
if (type.has_value()) {
return MakeVariableDecl(type->name(), TypeType(arena, *type));
}
Expand All @@ -94,7 +94,7 @@ absl::StatusOr<absl::optional<VariableDecl>> TypeCheckEnv::LookupTypeConstant(
return absl::nullopt;
}

absl::StatusOr<absl::optional<StructTypeField>> TypeCheckEnv::LookupStructField(
absl::StatusOr<std::optional<StructTypeField>> TypeCheckEnv::LookupStructField(
absl::string_view type_name, absl::string_view field_name) const {
// Check the type providers in registration order.
// Note: this doesn't allow for shadowing a type with a subset type of the
Expand Down
6 changes: 3 additions & 3 deletions checker/internal/type_checker_builder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ absl::StatusOr<FunctionDecl> MergeFunctionDecls(
return merged_decl;
}

absl::optional<FunctionDecl> FilterDecl(FunctionDecl decl,
const TypeCheckerSubset& subset) {
std::optional<FunctionDecl> FilterDecl(FunctionDecl decl,
const TypeCheckerSubset& subset) {
FunctionDecl filtered;
std::string name = decl.release_name();
std::vector<OverloadDecl> overloads = decl.release_overloads();
Expand Down Expand Up @@ -283,7 +283,7 @@ absl::Status TypeCheckerBuilderImpl::ApplyConfig(
for (FunctionDeclRecord& fn : config.functions) {
FunctionDecl decl = std::move(fn.decl);
if (subset != nullptr) {
absl::optional<FunctionDecl> filtered =
std::optional<FunctionDecl> filtered =
FilterDecl(std::move(decl), *subset);
if (!filtered.has_value()) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion checker/internal/type_checker_builder_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ TEST(ContextDeclsTest, CustomStructNotSupported) {
{});
class MyTypeProvider : public cel::TypeIntrospector {
public:
absl::StatusOr<absl::optional<Type>> FindTypeImpl(
absl::StatusOr<std::optional<Type>> FindTypeImpl(
absl::string_view name) const override {
if (name == "com.example.MyStruct") {
return common_internal::MakeBasicStructType("com.example.MyStruct");
Expand Down
20 changes: 10 additions & 10 deletions checker/internal/type_checker_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class ResolveVisitor : public AstVisitorBase {

// Lookup message type by name to support WellKnownType creation.
CEL_ASSIGN_OR_RETURN(
absl::optional<StructTypeField> field_info,
std::optional<StructTypeField> field_info,
env_->LookupStructField(resolved_name, field.name()));
if (!field_info.has_value()) {
ReportUndefinedField(field.id(), field.name(), resolved_name);
Expand All @@ -405,8 +405,8 @@ class ResolveVisitor : public AstVisitorBase {
return absl::OkStatus();
}

absl::optional<Type> CheckFieldType(int64_t expr_id, const Type& operand_type,
absl::string_view field_name);
std::optional<Type> CheckFieldType(int64_t expr_id, const Type& operand_type,
absl::string_view field_name);

void HandleOptSelect(const Expr& expr);
void HandleBlockIndex(const Expr* expr);
Expand Down Expand Up @@ -919,7 +919,7 @@ void ResolveVisitor::ResolveFunctionOverloads(const Expr& expr,
arg_types.push_back(GetDeducedType(&expr.call_expr().args()[i]));
}

absl::optional<TypeInferenceContext::OverloadResolution> resolution =
std::optional<TypeInferenceContext::OverloadResolution> resolution =
inference_context_->ResolveOverload(decl, arg_types, is_receiver);

if (!resolution.has_value()) {
Expand Down Expand Up @@ -968,7 +968,7 @@ const VariableDecl* absl_nullable ResolveVisitor::LookupGlobalIdentifier(
if (const VariableDecl* decl = env_->LookupVariable(name); decl != nullptr) {
return decl;
}
absl::StatusOr<absl::optional<VariableDecl>> constant =
absl::StatusOr<std::optional<VariableDecl>> constant =
env_->LookupTypeConstant(arena_, name);

if (!constant.ok()) {
Expand Down Expand Up @@ -1079,9 +1079,9 @@ void ResolveVisitor::ResolveQualifiedIdentifier(
}
}

absl::optional<Type> ResolveVisitor::CheckFieldType(int64_t id,
const Type& operand_type,
absl::string_view field) {
std::optional<Type> ResolveVisitor::CheckFieldType(int64_t id,
const Type& operand_type,
absl::string_view field) {
if (operand_type.kind() == TypeKind::kDyn ||
operand_type.kind() == TypeKind::kAny) {
return DynType();
Expand Down Expand Up @@ -1137,7 +1137,7 @@ void ResolveVisitor::ResolveSelectOperation(const Expr& expr,
const Expr& operand) {
const Type& operand_type = GetDeducedType(&operand);

absl::optional<Type> result_type;
std::optional<Type> result_type;
int64_t id = expr.id();
// Support short-hand optional chaining.
if (operand_type.IsOptional()) {
Expand Down Expand Up @@ -1184,7 +1184,7 @@ void ResolveVisitor::HandleOptSelect(const Expr& expr) {
operand_type = operand_type.GetOptional().GetParameter();
}

absl::optional<Type> field_type = CheckFieldType(
std::optional<Type> field_type = CheckFieldType(
expr.id(), operand_type, field->const_expr().string_value());
if (!field_type.has_value()) {
types_[&expr] = ErrorType();
Expand Down
8 changes: 4 additions & 4 deletions checker/internal/type_inference_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ FunctionOverloadInstance InstantiateFunctionOverload(

// Converts a wrapper type to its corresponding primitive type.
// Returns nullopt if the type is not a wrapper type.
absl::optional<Type> WrapperToPrimitive(const Type& t) {
std::optional<Type> WrapperToPrimitive(const Type& t) {
switch (t.kind()) {
case TypeKind::kBoolWrapper:
return BoolType();
Expand Down Expand Up @@ -286,7 +286,7 @@ bool TypeInferenceContext::IsAssignableInternal(
}

// Type is as concrete as it can be under current substitutions.
if (absl::optional<Type> wrapped_type = WrapperToPrimitive(to_subs);
if (std::optional<Type> wrapped_type = WrapperToPrimitive(to_subs);
wrapped_type.has_value()) {
return from_subs.IsNull() ||
IsAssignableInternal(*wrapped_type, from_subs,
Expand Down Expand Up @@ -531,11 +531,11 @@ bool TypeInferenceContext::IsAssignableWithConstraints(
return false;
}

absl::optional<TypeInferenceContext::OverloadResolution>
std::optional<TypeInferenceContext::OverloadResolution>
TypeInferenceContext::ResolveOverload(const FunctionDecl& decl,
absl::Span<const Type> argument_types,
bool is_receiver) {
absl::optional<Type> result_type;
std::optional<Type> result_type;

std::vector<OverloadDecl> matching_overloads;
for (const auto& ovl : decl.overloads()) {
Expand Down
Loading