Skip to content

Commit aed258d

Browse files
CEL Dev Teamcopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 917636319
1 parent 6fd7030 commit aed258d

8 files changed

Lines changed: 51 additions & 51 deletions

checker/internal/descriptor_pool_type_introspector.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace {
3535

3636
// Standard implementation for field lookups.
3737
// Avoids building a FieldTable and just checks the DescriptorPool directly.
38-
absl::StatusOr<absl::optional<StructTypeField>>
38+
absl::StatusOr<std::optional<StructTypeField>>
3939
FindStructTypeFieldByNameDirectly(
4040
const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
4141
absl::string_view type, absl::string_view name) {
@@ -60,7 +60,7 @@ FindStructTypeFieldByNameDirectly(
6060
// Standard implementation for listing fields.
6161
// Avoids building a FieldTable and just checks the DescriptorPool directly.
6262
absl::StatusOr<
63-
absl::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
63+
std::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
6464
ListStructTypeFieldsDirectly(
6565
const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
6666
absl::string_view type) {
@@ -88,7 +88,7 @@ ListStructTypeFieldsDirectly(
8888

8989
using Field = DescriptorPoolTypeIntrospector::Field;
9090

91-
absl::StatusOr<absl::optional<Type>>
91+
absl::StatusOr<std::optional<Type>>
9292
DescriptorPoolTypeIntrospector::FindTypeImpl(absl::string_view name) const {
9393
const google::protobuf::Descriptor* absl_nullable descriptor =
9494
descriptor_pool_->FindMessageTypeByName(name);
@@ -103,7 +103,7 @@ DescriptorPoolTypeIntrospector::FindTypeImpl(absl::string_view name) const {
103103
return absl::nullopt;
104104
}
105105

106-
absl::StatusOr<absl::optional<TypeIntrospector::EnumConstant>>
106+
absl::StatusOr<std::optional<TypeIntrospector::EnumConstant>>
107107
DescriptorPoolTypeIntrospector::FindEnumConstantImpl(
108108
absl::string_view type, absl::string_view value) const {
109109
const google::protobuf::EnumDescriptor* absl_nullable enum_descriptor =
@@ -124,7 +124,7 @@ DescriptorPoolTypeIntrospector::FindEnumConstantImpl(
124124
return absl::nullopt;
125125
}
126126

127-
absl::StatusOr<absl::optional<StructTypeField>>
127+
absl::StatusOr<std::optional<StructTypeField>>
128128
DescriptorPoolTypeIntrospector::FindStructTypeFieldByNameImpl(
129129
absl::string_view type, absl::string_view name) const {
130130
if (!use_json_name_) {
@@ -151,7 +151,7 @@ DescriptorPoolTypeIntrospector::FindStructTypeFieldByNameImpl(
151151
}
152152

153153
absl::StatusOr<
154-
absl::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
154+
std::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
155155
DescriptorPoolTypeIntrospector::ListFieldsForStructTypeImpl(
156156
absl::string_view type) const {
157157
if (!use_json_name_) {

checker/internal/descriptor_pool_type_introspector_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ TEST(DescriptorPoolTypeIntrospectorTest,
117117
internal::GetTestingDescriptorPool());
118118
introspector.set_use_json_name(true);
119119

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

@@ -132,7 +132,7 @@ TEST(DescriptorPoolTypeIntrospectorTest, ListFieldsForStructType) {
132132
DescriptorPoolTypeIntrospector introspector(
133133
internal::GetTestingDescriptorPool());
134134
absl::StatusOr<
135-
absl::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
135+
std::optional<std::vector<TypeIntrospector::StructTypeFieldListing>>>
136136
fields = introspector.ListFieldsForStructType(
137137
"cel.expr.conformance.proto3.TestAllTypes");
138138
ASSERT_THAT(fields, IsOkAndHolds(Optional(SizeIs(260))));

checker/internal/type_check_env.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const FunctionDecl* absl_nullable TypeCheckEnv::LookupFunction(
4848
return nullptr;
4949
}
5050

51-
absl::StatusOr<absl::optional<Type>> TypeCheckEnv::LookupTypeName(
51+
absl::StatusOr<std::optional<Type>> TypeCheckEnv::LookupTypeName(
5252
absl::string_view name) const {
5353
for (auto iter = type_providers_.begin(); iter != type_providers_.end();
5454
++iter) {
@@ -60,7 +60,7 @@ absl::StatusOr<absl::optional<Type>> TypeCheckEnv::LookupTypeName(
6060
return absl::nullopt;
6161
}
6262

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

80-
absl::StatusOr<absl::optional<VariableDecl>> TypeCheckEnv::LookupTypeConstant(
80+
absl::StatusOr<std::optional<VariableDecl>> TypeCheckEnv::LookupTypeConstant(
8181
google::protobuf::Arena* absl_nonnull arena, absl::string_view name) const {
82-
CEL_ASSIGN_OR_RETURN(absl::optional<Type> type, LookupTypeName(name));
82+
CEL_ASSIGN_OR_RETURN(std::optional<Type> type, LookupTypeName(name));
8383
if (type.has_value()) {
8484
return MakeVariableDecl(type->name(), TypeType(arena, *type));
8585
}
@@ -94,7 +94,7 @@ absl::StatusOr<absl::optional<VariableDecl>> TypeCheckEnv::LookupTypeConstant(
9494
return absl::nullopt;
9595
}
9696

97-
absl::StatusOr<absl::optional<StructTypeField>> TypeCheckEnv::LookupStructField(
97+
absl::StatusOr<std::optional<StructTypeField>> TypeCheckEnv::LookupStructField(
9898
absl::string_view type_name, absl::string_view field_name) const {
9999
// Check the type providers in registration order.
100100
// Note: this doesn't allow for shadowing a type with a subset type of the

checker/internal/type_checker_builder_impl.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ absl::StatusOr<FunctionDecl> MergeFunctionDecls(
158158
return merged_decl;
159159
}
160160

161-
absl::optional<FunctionDecl> FilterDecl(FunctionDecl decl,
162-
const TypeCheckerSubset& subset) {
161+
std::optional<FunctionDecl> FilterDecl(FunctionDecl decl,
162+
const TypeCheckerSubset& subset) {
163163
FunctionDecl filtered;
164164
std::string name = decl.release_name();
165165
std::vector<OverloadDecl> overloads = decl.release_overloads();
@@ -283,7 +283,7 @@ absl::Status TypeCheckerBuilderImpl::ApplyConfig(
283283
for (FunctionDeclRecord& fn : config.functions) {
284284
FunctionDecl decl = std::move(fn.decl);
285285
if (subset != nullptr) {
286-
absl::optional<FunctionDecl> filtered =
286+
std::optional<FunctionDecl> filtered =
287287
FilterDecl(std::move(decl), *subset);
288288
if (!filtered.has_value()) {
289289
continue;

checker/internal/type_checker_builder_impl_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ TEST(ContextDeclsTest, CustomStructNotSupported) {
144144
{});
145145
class MyTypeProvider : public cel::TypeIntrospector {
146146
public:
147-
absl::StatusOr<absl::optional<Type>> FindTypeImpl(
147+
absl::StatusOr<std::optional<Type>> FindTypeImpl(
148148
absl::string_view name) const override {
149149
if (name == "com.example.MyStruct") {
150150
return common_internal::MakeBasicStructType("com.example.MyStruct");

checker/internal/type_checker_impl.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class ResolveVisitor : public AstVisitorBase {
379379

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

408-
absl::optional<Type> CheckFieldType(int64_t expr_id, const Type& operand_type,
409-
absl::string_view field_name);
408+
std::optional<Type> CheckFieldType(int64_t expr_id, const Type& operand_type,
409+
absl::string_view field_name);
410410

411411
void HandleOptSelect(const Expr& expr);
412412
void HandleBlockIndex(const Expr* expr);
@@ -919,7 +919,7 @@ void ResolveVisitor::ResolveFunctionOverloads(const Expr& expr,
919919
arg_types.push_back(GetDeducedType(&expr.call_expr().args()[i]));
920920
}
921921

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

925925
if (!resolution.has_value()) {
@@ -968,7 +968,7 @@ const VariableDecl* absl_nullable ResolveVisitor::LookupGlobalIdentifier(
968968
if (const VariableDecl* decl = env_->LookupVariable(name); decl != nullptr) {
969969
return decl;
970970
}
971-
absl::StatusOr<absl::optional<VariableDecl>> constant =
971+
absl::StatusOr<std::optional<VariableDecl>> constant =
972972
env_->LookupTypeConstant(arena_, name);
973973

974974
if (!constant.ok()) {
@@ -1079,9 +1079,9 @@ void ResolveVisitor::ResolveQualifiedIdentifier(
10791079
}
10801080
}
10811081

1082-
absl::optional<Type> ResolveVisitor::CheckFieldType(int64_t id,
1083-
const Type& operand_type,
1084-
absl::string_view field) {
1082+
std::optional<Type> ResolveVisitor::CheckFieldType(int64_t id,
1083+
const Type& operand_type,
1084+
absl::string_view field) {
10851085
if (operand_type.kind() == TypeKind::kDyn ||
10861086
operand_type.kind() == TypeKind::kAny) {
10871087
return DynType();
@@ -1137,7 +1137,7 @@ void ResolveVisitor::ResolveSelectOperation(const Expr& expr,
11371137
const Expr& operand) {
11381138
const Type& operand_type = GetDeducedType(&operand);
11391139

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

1187-
absl::optional<Type> field_type = CheckFieldType(
1187+
std::optional<Type> field_type = CheckFieldType(
11881188
expr.id(), operand_type, field->const_expr().string_value());
11891189
if (!field_type.has_value()) {
11901190
types_[&expr] = ErrorType();

checker/internal/type_inference_context.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ FunctionOverloadInstance InstantiateFunctionOverload(
133133

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

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

534-
absl::optional<TypeInferenceContext::OverloadResolution>
534+
std::optional<TypeInferenceContext::OverloadResolution>
535535
TypeInferenceContext::ResolveOverload(const FunctionDecl& decl,
536536
absl::Span<const Type> argument_types,
537537
bool is_receiver) {
538-
absl::optional<Type> result_type;
538+
std::optional<Type> result_type;
539539

540540
std::vector<OverloadDecl> matching_overloads;
541541
for (const auto& ovl : decl.overloads()) {

0 commit comments

Comments
 (0)