diff --git a/checker/BUILD b/checker/BUILD index b83be9080..ad0b876db 100644 --- a/checker/BUILD +++ b/checker/BUILD @@ -64,8 +64,8 @@ cc_test( deps = [ ":type_check_issue", ":validation_result", + "//common:ast", "//common:source", - "//common/ast:ast_impl", "//internal:testing", "@com_google_absl//absl/status", "@com_google_absl//absl/status:status_matchers", @@ -171,7 +171,6 @@ cc_test( "//common:constant", "//common:decl", "//common:type", - "//common/ast:ast_impl", "//common/ast:expr", "//internal:testing", "//internal:testing_descriptor_pool", @@ -209,7 +208,6 @@ cc_test( ":type_checker_builder", ":type_checker_builder_factory", "//checker/internal:test_ast_helpers", - "//common/ast:ast_impl", "//common/ast:expr", "//internal:testing", "//internal:testing_descriptor_pool", diff --git a/checker/internal/BUILD b/checker/internal/BUILD index 9bcf73582..637fef697 100644 --- a/checker/internal/BUILD +++ b/checker/internal/BUILD @@ -42,7 +42,6 @@ cc_test( deps = [ ":test_ast_helpers", "//common:ast", - "//common/ast:ast_impl", "//internal:testing", "@com_google_absl//absl/status", "@com_google_absl//absl/status:status_matchers", @@ -139,7 +138,6 @@ cc_library( "//common:source", "//common:type", "//common:type_kind", - "//common/ast:ast_impl", "//common/ast:expr", "//internal:lexis", "//internal:status_macros", @@ -203,9 +201,9 @@ cc_test( "//checker:checker_options", "//checker:type_checker", "//checker:validation_result", + "//common:ast", "//common:decl", "//common:type", - "//common/ast:ast_impl", "//common/ast:expr", "//internal:testing", "//internal:testing_descriptor_pool", diff --git a/checker/internal/type_checker_builder_impl_test.cc b/checker/internal/type_checker_builder_impl_test.cc index 9f885f79d..83f1e370f 100644 --- a/checker/internal/type_checker_builder_impl_test.cc +++ b/checker/internal/type_checker_builder_impl_test.cc @@ -27,7 +27,7 @@ #include "checker/internal/test_ast_helpers.h" #include "checker/type_checker.h" #include "checker/validation_result.h" -#include "common/ast/ast_impl.h" +#include "common/ast.h" #include "common/ast/expr.h" #include "common/decl.h" #include "common/type.h" @@ -42,11 +42,10 @@ namespace { using ::absl_testing::IsOk; using ::absl_testing::StatusIs; -using AstType = cel::ast_internal::Type; struct ContextDeclsTestCase { std::string expr; - AstType expected_type; + TypeSpec expected_type; }; class ContextDeclsFieldsDefinedTest @@ -73,50 +72,51 @@ INSTANTIATE_TEST_SUITE_P( TestAllTypes, ContextDeclsFieldsDefinedTest, testing::Values( ContextDeclsTestCase{"single_int64", - AstType(ast_internal::PrimitiveType::kInt64)}, + TypeSpec(ast_internal::PrimitiveType::kInt64)}, ContextDeclsTestCase{"single_uint32", - AstType(ast_internal::PrimitiveType::kUint64)}, + TypeSpec(ast_internal::PrimitiveType::kUint64)}, ContextDeclsTestCase{"single_double", - AstType(ast_internal::PrimitiveType::kDouble)}, + TypeSpec(ast_internal::PrimitiveType::kDouble)}, ContextDeclsTestCase{"single_string", - AstType(ast_internal::PrimitiveType::kString)}, + TypeSpec(ast_internal::PrimitiveType::kString)}, ContextDeclsTestCase{"single_any", - AstType(ast_internal::WellKnownType::kAny)}, + TypeSpec(ast_internal::WellKnownType::kAny)}, ContextDeclsTestCase{"single_duration", - AstType(ast_internal::WellKnownType::kDuration)}, + TypeSpec(ast_internal::WellKnownType::kDuration)}, ContextDeclsTestCase{"single_bool_wrapper", - AstType(ast_internal::PrimitiveTypeWrapper( + TypeSpec(ast_internal::PrimitiveTypeWrapper( ast_internal::PrimitiveType::kBool))}, ContextDeclsTestCase{ "list_value", - AstType(ast_internal::ListType( - std::make_unique(ast_internal::DynamicType())))}, + TypeSpec(ast_internal::ListType( + std::make_unique(ast_internal::DynamicType())))}, ContextDeclsTestCase{ "standalone_message", - AstType(ast_internal::MessageType( + TypeSpec(ast_internal::MessageType( "cel.expr.conformance.proto3.TestAllTypes.NestedMessage"))}, ContextDeclsTestCase{"standalone_enum", - AstType(ast_internal::PrimitiveType::kInt64)}, + TypeSpec(ast_internal::PrimitiveType::kInt64)}, ContextDeclsTestCase{ "repeated_bytes", - AstType(ast_internal::ListType(std::make_unique( + TypeSpec(ast_internal::ListType(std::make_unique( ast_internal::PrimitiveType::kBytes)))}, ContextDeclsTestCase{ "repeated_nested_message", - AstType(ast_internal::ListType(std::make_unique< - AstType>(ast_internal::MessageType( + TypeSpec(ast_internal::ListType(std::make_unique< + TypeSpec>(ast_internal::MessageType( "cel.expr.conformance.proto3.TestAllTypes.NestedMessage"))))}, ContextDeclsTestCase{ "map_int32_timestamp", - AstType(ast_internal::MapType( - std::make_unique(ast_internal::PrimitiveType::kInt64), - std::make_unique( + TypeSpec(ast_internal::MapType( + std::make_unique(ast_internal::PrimitiveType::kInt64), + std::make_unique( ast_internal::WellKnownType::kTimestamp)))}, ContextDeclsTestCase{ "single_struct", - AstType(ast_internal::MapType( - std::make_unique(ast_internal::PrimitiveType::kString), - std::make_unique(ast_internal::DynamicType())))})); + TypeSpec(ast_internal::MapType( + std::make_unique( + ast_internal::PrimitiveType::kString), + std::make_unique(ast_internal::DynamicType())))})); TEST(ContextDeclsTest, ErrorOnDuplicateContextDeclaration) { TypeCheckerBuilderImpl builder(internal::GetSharedTestingDescriptorPool(), @@ -324,7 +324,7 @@ TEST(TypeCheckerBuilderImplTest, ReplaceVariable) { const auto& checked_ast = *result.GetAst(); EXPECT_EQ(checked_ast.GetReturnType(), - AstType(ast_internal::PrimitiveType::kString)); + TypeSpec(ast_internal::PrimitiveType::kString)); } } // namespace diff --git a/checker/internal/type_checker_impl.cc b/checker/internal/type_checker_impl.cc index b051032cd..f75ff7ea0 100644 --- a/checker/internal/type_checker_impl.cc +++ b/checker/internal/type_checker_impl.cc @@ -40,7 +40,6 @@ #include "checker/type_check_issue.h" #include "checker/validation_result.h" #include "common/ast.h" -#include "common/ast/ast_impl.h" #include "common/ast/expr.h" #include "common/ast_rewrite.h" #include "common/ast_traverse.h" diff --git a/checker/optional_test.cc b/checker/optional_test.cc index 877abf08d..580cd381c 100644 --- a/checker/optional_test.cc +++ b/checker/optional_test.cc @@ -28,7 +28,6 @@ #include "checker/type_checker.h" #include "checker/type_checker_builder.h" #include "checker/type_checker_builder_factory.h" -#include "common/ast/ast_impl.h" #include "common/ast/expr.h" #include "internal/testing.h" #include "internal/testing_descriptor_pool.h" diff --git a/checker/validation_result_test.cc b/checker/validation_result_test.cc index f41dff9e8..dd9b05a4c 100644 --- a/checker/validation_result_test.cc +++ b/checker/validation_result_test.cc @@ -20,7 +20,7 @@ #include "absl/status/status.h" #include "absl/status/status_matchers.h" #include "checker/type_check_issue.h" -#include "common/ast/ast_impl.h" +#include "common/ast.h" #include "common/source.h" #include "internal/testing.h" @@ -29,7 +29,6 @@ namespace { using ::absl_testing::IsOkAndHolds; using ::absl_testing::StatusIs; -using ::cel::ast_internal::AstImpl; using ::testing::_; using ::testing::IsNull; using ::testing::NotNull; @@ -38,7 +37,7 @@ using ::testing::SizeIs; using Severity = TypeCheckIssue::Severity; TEST(ValidationResultTest, IsValidWithAst) { - ValidationResult result(std::make_unique(), {}); + ValidationResult result(std::make_unique(), {}); EXPECT_TRUE(result.IsValid()); EXPECT_THAT(result.GetAst(), NotNull()); EXPECT_THAT(result.ReleaseAst(), IsOkAndHolds(NotNull())); diff --git a/common/BUILD b/common/BUILD index 03b687b45..1985b91a9 100644 --- a/common/BUILD +++ b/common/BUILD @@ -33,6 +33,17 @@ cc_library( ], ) +cc_test( + name = "ast_test", + srcs = ["ast_test.cc"], + deps = [ + ":ast", + ":expr", + "//internal:testing", + "@com_google_absl//absl/container:flat_hash_map", + ], +) + cc_library( name = "expr", srcs = ["expr.cc"], @@ -176,7 +187,6 @@ cc_test( ":ast_rewrite", ":ast_visitor", ":expr", - "//common/ast:ast_impl", "//common/ast:expr_proto", "//extensions/protobuf:ast_converters", "//internal:testing", @@ -1031,7 +1041,6 @@ cc_library( ":constant", ":expr", "//base:ast", - "//common/ast:ast_impl", "//common/ast:constant_proto", "//common/ast:expr", "//common/ast:expr_proto", @@ -1062,7 +1071,6 @@ cc_test( ":expr", ":source", ":type", - "//common/ast:ast_impl", "//common/ast:expr", "//compiler", "//compiler:compiler_factory", diff --git a/common/ast/BUILD b/common/ast/BUILD index dfa972d53..a973c160b 100644 --- a/common/ast/BUILD +++ b/common/ast/BUILD @@ -81,19 +81,6 @@ cc_library( ":metadata", "//common:ast", "//common:expr", - "//internal:casts", - ], -) - -cc_test( - name = "ast_impl_test", - srcs = ["ast_impl_test.cc"], - deps = [ - ":ast_impl", - ":expr", - "//common:ast", - "//internal:testing", - "@com_google_absl//absl/container:flat_hash_map", ], ) diff --git a/common/ast_proto.cc b/common/ast_proto.cc index 24ba55a73..3f8df26f0 100644 --- a/common/ast_proto.cc +++ b/common/ast_proto.cc @@ -31,7 +31,6 @@ #include "absl/status/statusor.h" #include "absl/types/variant.h" #include "common/ast.h" -#include "common/ast/ast_impl.h" #include "common/ast/constant_proto.h" #include "common/ast/expr.h" #include "common/ast/expr_proto.h" @@ -44,7 +43,6 @@ namespace cel { namespace { using ::cel::ast_internal::AbstractType; -using ::cel::ast_internal::AstImpl; using ::cel::ast_internal::ConstantFromProto; using ::cel::ast_internal::ConstantToProto; using ::cel::ast_internal::DynamicType; @@ -487,8 +485,8 @@ absl::StatusOr> CreateAstFromParsedExpr( CEL_ASSIGN_OR_RETURN(runtime_source_info, ConvertProtoSourceInfoToNative(*source_info)); } - return std::make_unique( - std::move(runtime_expr), std::move(runtime_source_info)); + return std::make_unique(std::move(runtime_expr), + std::move(runtime_source_info)); } absl::StatusOr> CreateAstFromParsedExpr( @@ -513,7 +511,7 @@ absl::StatusOr> CreateAstFromCheckedExpr( CEL_ASSIGN_OR_RETURN(SourceInfo source_info, ConvertProtoSourceInfoToNative( checked_expr.source_info())); - AstImpl::ReferenceMap reference_map; + Ast::ReferenceMap reference_map; for (const auto& pair : checked_expr.reference_map()) { auto native_reference = ConvertProtoReferenceToNative(pair.second); if (!native_reference.ok()) { @@ -521,7 +519,7 @@ absl::StatusOr> CreateAstFromCheckedExpr( } reference_map.emplace(pair.first, *(std::move(native_reference))); } - AstImpl::TypeMap type_map; + Ast::TypeMap type_map; for (const auto& pair : checked_expr.type_map()) { auto native_type = ConvertProtoTypeToNative(pair.second); if (!native_type.ok()) { @@ -530,9 +528,9 @@ absl::StatusOr> CreateAstFromCheckedExpr( type_map.emplace(pair.first, *(std::move(native_type))); } - return std::make_unique( - std::move(expr), std::move(source_info), std::move(reference_map), - std::move(type_map), checked_expr.expr_version()); + return std::make_unique(std::move(expr), std::move(source_info), + std::move(reference_map), std::move(type_map), + checked_expr.expr_version()); } absl::Status AstToCheckedExpr( diff --git a/common/ast_rewrite_test.cc b/common/ast_rewrite_test.cc index 679c4caa2..5417b23ac 100644 --- a/common/ast_rewrite_test.cc +++ b/common/ast_rewrite_test.cc @@ -21,7 +21,6 @@ #include "cel/expr/syntax.pb.h" #include "absl/status/status_matchers.h" #include "common/ast.h" -#include "common/ast/ast_impl.h" #include "common/ast/expr_proto.h" #include "common/ast_visitor.h" #include "common/expr.h" @@ -35,7 +34,6 @@ namespace cel { namespace { using ::absl_testing::IsOk; -using ::cel::ast_internal::AstImpl; using ::cel::ast_internal::ExprFromProto; using ::cel::extensions::CreateAstFromParsedExpr; using ::testing::_; diff --git a/common/ast/ast_impl_test.cc b/common/ast_test.cc similarity index 53% rename from common/ast/ast_impl_test.cc rename to common/ast_test.cc index e9eb96e37..744b9e8d3 100644 --- a/common/ast/ast_impl_test.cc +++ b/common/ast_test.cc @@ -12,16 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "common/ast/ast_impl.h" +#include "common/ast.h" #include #include "absl/container/flat_hash_map.h" -#include "common/ast.h" -#include "common/ast/expr.h" +#include "common/expr.h" #include "internal/testing.h" -namespace cel::ast_internal { +namespace cel { namespace { using ::testing::Pointee; @@ -51,18 +50,17 @@ TEST(AstImpl, RawExprCtor) { source_info.mutable_positions()[5] = 6; // act - AstImpl ast_impl(std::move(expr), std::move(source_info)); - Ast& ast = ast_impl; + Ast ast(std::move(expr), std::move(source_info)); // assert - ASSERT_FALSE(ast.IsChecked()); - EXPECT_EQ(ast_impl.GetTypeOrDyn(1), Type(DynamicType())); - EXPECT_EQ(ast_impl.GetReturnType(), Type(DynamicType())); - EXPECT_EQ(ast_impl.GetReference(1), nullptr); - EXPECT_TRUE(ast_impl.root_expr().has_call_expr()); - EXPECT_EQ(ast_impl.root_expr().call_expr().function(), "_==_"); - EXPECT_EQ(ast_impl.root_expr().id(), 5); // Parser IDs leaf to root. - EXPECT_EQ(ast_impl.source_info().positions().at(5), 6); // start pos of == + ASSERT_FALSE(ast.is_checked()); + EXPECT_EQ(ast.GetTypeOrDyn(1), TypeSpec(DynTypeSpec())); + EXPECT_EQ(ast.GetReturnType(), TypeSpec(DynTypeSpec())); + EXPECT_EQ(ast.GetReference(1), nullptr); + EXPECT_TRUE(ast.root_expr().has_call_expr()); + EXPECT_EQ(ast.root_expr().call_expr().function(), "_==_"); + EXPECT_EQ(ast.root_expr().id(), 5); // Parser IDs leaf to root. + EXPECT_EQ(ast.source_info().positions().at(5), 6); // start pos of == } TEST(AstImpl, CheckedExprCtor) { @@ -71,29 +69,27 @@ TEST(AstImpl, CheckedExprCtor) { expr.set_id(1); Reference ref; ref.set_name("com.int_value"); - AstImpl::ReferenceMap reference_map; + Ast::ReferenceMap reference_map; reference_map[1] = Reference(ref); - AstImpl::TypeMap type_map; - type_map[1] = Type(PrimitiveType::kInt64); + Ast::TypeMap type_map; + type_map[1] = TypeSpec(PrimitiveType::kInt64); SourceInfo source_info; source_info.set_syntax_version("1.0"); - AstImpl ast_impl(std::move(expr), std::move(source_info), - std::move(reference_map), std::move(type_map), "1.0"); - Ast& ast = ast_impl; + Ast ast(std::move(expr), std::move(source_info), std::move(reference_map), + std::move(type_map), "1.0"); - ASSERT_TRUE(ast.IsChecked()); - EXPECT_EQ(ast_impl.GetTypeOrDyn(1), Type(PrimitiveType::kInt64)); - EXPECT_THAT(ast_impl.GetReference(1), - Pointee(Truly([&ref](const Reference& arg) { + ASSERT_TRUE(ast.is_checked()); + EXPECT_EQ(ast.GetTypeOrDyn(1), TypeSpec(PrimitiveType::kInt64)); + EXPECT_THAT(ast.GetReference(1), Pointee(Truly([&ref](const Reference& arg) { return arg.name() == ref.name(); }))); - EXPECT_EQ(ast_impl.GetReturnType(), Type(PrimitiveType::kInt64)); - EXPECT_TRUE(ast_impl.root_expr().has_ident_expr()); - EXPECT_EQ(ast_impl.root_expr().ident_expr().name(), "int_value"); - EXPECT_EQ(ast_impl.root_expr().id(), 1); - EXPECT_EQ(ast_impl.source_info().syntax_version(), "1.0"); - EXPECT_EQ(ast_impl.expr_version(), "1.0"); + EXPECT_EQ(ast.GetReturnType(), TypeSpec(PrimitiveType::kInt64)); + EXPECT_TRUE(ast.root_expr().has_ident_expr()); + EXPECT_EQ(ast.root_expr().ident_expr().name(), "int_value"); + EXPECT_EQ(ast.root_expr().id(), 1); + EXPECT_EQ(ast.source_info().syntax_version(), "1.0"); + EXPECT_EQ(ast.expr_version(), "1.0"); } TEST(AstImpl, CheckedExprDeepCopy) { @@ -103,39 +99,38 @@ TEST(AstImpl, CheckedExprDeepCopy) { root.mutable_call_expr().mutable_args().resize(2); auto& lhs = root.mutable_call_expr().mutable_args()[0]; auto& rhs = root.mutable_call_expr().mutable_args()[1]; - AstImpl::TypeMap type_map; - AstImpl::ReferenceMap reference_map; + Ast::TypeMap type_map; + Ast::ReferenceMap reference_map; SourceInfo source_info; - type_map[3] = Type(PrimitiveType::kBool); + type_map[3] = TypeSpec(PrimitiveType::kBool); lhs.mutable_ident_expr().set_name("int_value"); lhs.set_id(1); Reference ref; ref.set_name("com.int_value"); reference_map[1] = std::move(ref); - type_map[1] = Type(PrimitiveType::kInt64); + type_map[1] = TypeSpec(PrimitiveType::kInt64); rhs.mutable_const_expr().set_int_value(2); rhs.set_id(2); - type_map[2] = Type(PrimitiveType::kInt64); + type_map[2] = TypeSpec(PrimitiveType::kInt64); source_info.set_syntax_version("1.0"); - AstImpl ast_impl(std::move(root), std::move(source_info), - std::move(reference_map), std::move(type_map), "1.0"); - Ast& ast = ast_impl; + Ast ast(std::move(root), std::move(source_info), std::move(reference_map), + std::move(type_map), "1.0"); ASSERT_TRUE(ast.IsChecked()); - EXPECT_EQ(ast_impl.GetTypeOrDyn(1), Type(PrimitiveType::kInt64)); - EXPECT_THAT(ast_impl.GetReference(1), Pointee(Truly([](const Reference& arg) { + EXPECT_EQ(ast.GetTypeOrDyn(1), TypeSpec(PrimitiveType::kInt64)); + EXPECT_THAT(ast.GetReference(1), Pointee(Truly([](const Reference& arg) { return arg.name() == "com.int_value"; }))); - EXPECT_EQ(ast_impl.GetReturnType(), Type(PrimitiveType::kBool)); - EXPECT_TRUE(ast_impl.root_expr().has_call_expr()); - EXPECT_EQ(ast_impl.root_expr().call_expr().function(), "_==_"); - EXPECT_EQ(ast_impl.root_expr().id(), 3); - EXPECT_EQ(ast_impl.source_info().syntax_version(), "1.0"); + EXPECT_EQ(ast.GetReturnType(), TypeSpec(PrimitiveType::kBool)); + EXPECT_TRUE(ast.root_expr().has_call_expr()); + EXPECT_EQ(ast.root_expr().call_expr().function(), "_==_"); + EXPECT_EQ(ast.root_expr().id(), 3); + EXPECT_EQ(ast.source_info().syntax_version(), "1.0"); } } // namespace -} // namespace cel::ast_internal +} // namespace cel diff --git a/eval/compiler/BUILD b/eval/compiler/BUILD index 118311455..efbe09f1b 100644 --- a/eval/compiler/BUILD +++ b/eval/compiler/BUILD @@ -33,7 +33,6 @@ cc_library( "//common:expr", "//common:native_type", "//common:value", - "//common/ast:ast_impl", "//eval/eval:direct_expression_step", "//eval/eval:evaluator_core", "//eval/eval:trace_step", @@ -109,7 +108,6 @@ cc_library( "//common:kind", "//common:type", "//common:value", - "//common/ast:ast_impl", "//common/ast:expr", "//eval/eval:comprehension_step", "//eval/eval:const_value_step", @@ -355,7 +353,6 @@ cc_test( "//base:ast", "//common:expr", "//common:value", - "//common/ast:ast_impl", "//eval/eval:const_value_step", "//eval/eval:create_list_step", "//eval/eval:create_map_step", @@ -441,8 +438,8 @@ cc_test( ":resolver", "//base:ast", "//base:builtins", + "//common:ast", "//common:expr", - "//common/ast:ast_impl", "//common/ast:expr", "//common/ast:expr_proto", "//eval/public:builtin_func_registrar", @@ -450,7 +447,6 @@ cc_test( "//eval/public:cel_function_registry", "//eval/public:cel_value", "//extensions/protobuf:ast_converters", - "//internal:casts", "//internal:proto_matchers", "//internal:testing", "//runtime:runtime_issue", @@ -458,7 +454,6 @@ cc_test( "//runtime/internal:issue_collector", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log:absl_check", - "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_cel_spec//proto/cel/expr:syntax_cc_proto", @@ -520,7 +515,6 @@ cc_library( "//common:expr", "//common:native_type", "//common:value", - "//common/ast:ast_impl", "//common/ast:expr", "//eval/eval:compiler_constant_step", "//eval/eval:direct_expression_step", @@ -596,7 +590,6 @@ cc_library( "//common:ast", "//common:expr", "//common:value", - "//common/ast:ast_impl", "//eval/eval:evaluator_core", "//eval/eval:expression_step_base", "@com_google_absl//absl/functional:any_invocable", diff --git a/eval/compiler/flat_expr_builder.cc b/eval/compiler/flat_expr_builder.cc index dcf407a52..31857fa9b 100644 --- a/eval/compiler/flat_expr_builder.cc +++ b/eval/compiler/flat_expr_builder.cc @@ -52,7 +52,6 @@ #include "base/type_provider.h" #include "common/allocator.h" #include "common/ast.h" -#include "common/ast/ast_impl.h" #include "common/ast/expr.h" #include "common/ast_traverse.h" #include "common/ast_visitor.h" @@ -99,7 +98,6 @@ using ::cel::AstTraverse; using ::cel::RuntimeIssue; using ::cel::StringValue; using ::cel::Value; -using ::cel::ast_internal::AstImpl; using ::cel::runtime_internal::ConvertConstant; using ::cel::runtime_internal::GetLegacyRuntimeTypeProvider; using ::cel::runtime_internal::GetRuntimeTypeProvider; diff --git a/eval/compiler/qualified_reference_resolver_test.cc b/eval/compiler/qualified_reference_resolver_test.cc index d470c3ccb..329cceb0d 100644 --- a/eval/compiler/qualified_reference_resolver_test.cc +++ b/eval/compiler/qualified_reference_resolver_test.cc @@ -21,12 +21,11 @@ #include "cel/expr/syntax.pb.h" #include "absl/container/flat_hash_map.h" #include "absl/log/absl_check.h" -#include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "base/ast.h" #include "base/builtins.h" -#include "common/ast/ast_impl.h" +#include "common/ast.h" #include "common/ast/expr.h" #include "common/ast/expr_proto.h" #include "common/expr.h" @@ -36,7 +35,6 @@ #include "eval/public/cel_function_registry.h" #include "eval/public/cel_value.h" #include "extensions/protobuf/ast_converters.h" -#include "internal/casts.h" #include "internal/proto_matchers.h" #include "internal/testing.h" #include "runtime/internal/issue_collector.h" @@ -53,7 +51,6 @@ using ::absl_testing::StatusIs; using ::cel::Ast; using ::cel::Expr; using ::cel::RuntimeIssue; -using ::cel::ast_internal::AstImpl; using ::cel::ast_internal::ExprToProto; using ::cel::ast_internal::SourceInfo; using ::cel::internal::test::EqualsProto; @@ -109,11 +106,10 @@ MATCHER_P(StatusCodeIs, x, "") { return status.code() == x; } -std::unique_ptr ParseTestProto(const std::string& pb) { +std::unique_ptr ParseTestProto(const std::string& pb) { cel::expr::Expr expr; EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(pb, &expr)); - return absl::WrapUnique(cel::internal::down_cast( - cel::extensions::CreateAstFromParsedExpr(expr).value().release())); + return cel::extensions::CreateAstFromParsedExpr(expr).value(); } std::vector ExtractIssuesStatus(const IssueCollector& issues) { @@ -131,7 +127,7 @@ cel::expr::Expr ExprToProtoOrDie(const Expr& expr) { } TEST(ResolveReferences, Basic) { - std::unique_ptr expr_ast = ParseTestProto(kExpr); + std::unique_ptr expr_ast = ParseTestProto(kExpr); expr_ast->mutable_reference_map()[2].set_name("foo.bar.var1"); expr_ast->mutable_reference_map()[5].set_name("bar.foo.var2"); IssueCollector issues(RuntimeIssue::Severity::kError); @@ -159,7 +155,7 @@ TEST(ResolveReferences, Basic) { } TEST(ResolveReferences, ReturnsFalseIfNoChanges) { - std::unique_ptr expr_ast = ParseTestProto(kExpr); + std::unique_ptr expr_ast = ParseTestProto(kExpr); IssueCollector issues(RuntimeIssue::Severity::kError); CelFunctionRegistry func_registry; cel::TypeRegistry type_registry; @@ -178,7 +174,7 @@ TEST(ResolveReferences, ReturnsFalseIfNoChanges) { } TEST(ResolveReferences, NamespacedIdent) { - std::unique_ptr expr_ast = ParseTestProto(kExpr); + std::unique_ptr expr_ast = ParseTestProto(kExpr); SourceInfo source_info; IssueCollector issues(RuntimeIssue::Severity::kError); CelFunctionRegistry func_registry; @@ -219,7 +215,7 @@ TEST(ResolveReferences, NamespacedIdent) { } TEST(ResolveReferences, WarningOnPresenceTest) { - std::unique_ptr expr_ast = ParseTestProto(R"pb( + std::unique_ptr expr_ast = ParseTestProto(R"pb( id: 1 select_expr { field: "var1" @@ -283,7 +279,7 @@ constexpr char kEnumExpr[] = R"( )"; TEST(ResolveReferences, EnumConstReferenceUsed) { - std::unique_ptr expr_ast = ParseTestProto(kEnumExpr); + std::unique_ptr expr_ast = ParseTestProto(kEnumExpr); SourceInfo source_info; CelFunctionRegistry func_registry; @@ -316,7 +312,7 @@ TEST(ResolveReferences, EnumConstReferenceUsed) { } TEST(ResolveReferences, EnumConstReferenceUsedSelect) { - std::unique_ptr expr_ast = ParseTestProto(kEnumExpr); + std::unique_ptr expr_ast = ParseTestProto(kEnumExpr); SourceInfo source_info; CelFunctionRegistry func_registry; @@ -349,7 +345,7 @@ TEST(ResolveReferences, EnumConstReferenceUsedSelect) { } TEST(ResolveReferences, ConstReferenceSkipped) { - std::unique_ptr expr_ast = ParseTestProto(kExpr); + std::unique_ptr expr_ast = ParseTestProto(kExpr); SourceInfo source_info; CelFunctionRegistry func_registry; @@ -412,7 +408,7 @@ call_expr { })"; TEST(ResolveReferences, FunctionReferenceBasic) { - std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); SourceInfo source_info; CelFunctionRegistry func_registry; @@ -435,7 +431,7 @@ TEST(ResolveReferences, FunctionReferenceBasic) { } TEST(ResolveReferences, FunctionReferenceMissingOverloadDetected) { - std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); SourceInfo source_info; CelFunctionRegistry func_registry; @@ -454,7 +450,7 @@ TEST(ResolveReferences, FunctionReferenceMissingOverloadDetected) { } TEST(ResolveReferences, SpecialBuiltinsNotWarned) { - std::unique_ptr expr_ast = ParseTestProto(R"pb( + std::unique_ptr expr_ast = ParseTestProto(R"pb( id: 1 call_expr { function: "*" @@ -492,7 +488,7 @@ TEST(ResolveReferences, SpecialBuiltinsNotWarned) { TEST(ResolveReferences, FunctionReferenceMissingOverloadDetectedAndMissingReference) { - std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); SourceInfo source_info; CelFunctionRegistry func_registry; @@ -515,7 +511,7 @@ TEST(ResolveReferences, } TEST(ResolveReferences, EmulatesEagerFailing) { - std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); SourceInfo source_info; CelFunctionRegistry func_registry; @@ -532,7 +528,7 @@ TEST(ResolveReferences, EmulatesEagerFailing) { } TEST(ResolveReferences, FunctionReferenceToWrongExprKind) { - std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kExtensionAndExpr); SourceInfo source_info; IssueCollector issues(RuntimeIssue::Severity::kError); @@ -569,8 +565,7 @@ call_expr { })"; TEST(ResolveReferences, FunctionReferenceWithTargetNoChange) { - std::unique_ptr expr_ast = - ParseTestProto(kReceiverCallExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kReceiverCallExtensionAndExpr); SourceInfo source_info; IssueCollector issues(RuntimeIssue::Severity::kError); @@ -591,8 +586,7 @@ TEST(ResolveReferences, FunctionReferenceWithTargetNoChange) { TEST(ResolveReferences, FunctionReferenceWithTargetNoChangeMissingOverloadDetected) { - std::unique_ptr expr_ast = - ParseTestProto(kReceiverCallExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kReceiverCallExtensionAndExpr); SourceInfo source_info; IssueCollector issues(RuntimeIssue::Severity::kError); @@ -611,8 +605,7 @@ TEST(ResolveReferences, } TEST(ResolveReferences, FunctionReferenceWithTargetToNamespacedFunction) { - std::unique_ptr expr_ast = - ParseTestProto(kReceiverCallExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kReceiverCallExtensionAndExpr); SourceInfo source_info; IssueCollector issues(RuntimeIssue::Severity::kError); @@ -643,8 +636,7 @@ TEST(ResolveReferences, FunctionReferenceWithTargetToNamespacedFunction) { TEST(ResolveReferences, FunctionReferenceWithTargetToNamespacedFunctionInContainer) { - std::unique_ptr expr_ast = - ParseTestProto(kReceiverCallExtensionAndExpr); + std::unique_ptr expr_ast = ParseTestProto(kReceiverCallExtensionAndExpr); SourceInfo source_info; expr_ast->mutable_reference_map()[1].mutable_overload_id().push_back( @@ -701,7 +693,7 @@ call_expr { })"; TEST(ResolveReferences, FunctionReferenceWithHasTargetNoChange) { - std::unique_ptr expr_ast = + std::unique_ptr expr_ast = ParseTestProto(kReceiverCallHasExtensionAndExpr); SourceInfo source_info; @@ -794,7 +786,7 @@ comprehension_expr: { } )"; TEST(ResolveReferences, EnumConstReferenceUsedInComprehension) { - std::unique_ptr expr_ast = ParseTestProto(kComprehensionExpr); + std::unique_ptr expr_ast = ParseTestProto(kComprehensionExpr); SourceInfo source_info; @@ -888,7 +880,7 @@ TEST(ResolveReferences, EnumConstReferenceUsedInComprehension) { TEST(ResolveReferences, ReferenceToId0Warns) { // ID 0 is unsupported since it is not normally used by parsers and is // ambiguous as an intentional ID or default for unset field. - std::unique_ptr expr_ast = ParseTestProto(R"pb( + std::unique_ptr expr_ast = ParseTestProto(R"pb( id: 0 select_expr { operand { diff --git a/eval/compiler/regex_precompilation_optimization.cc b/eval/compiler/regex_precompilation_optimization.cc index e139492f1..7f5759c09 100644 --- a/eval/compiler/regex_precompilation_optimization.cc +++ b/eval/compiler/regex_precompilation_optimization.cc @@ -28,7 +28,6 @@ #include "absl/types/optional.h" #include "base/builtins.h" #include "common/ast.h" -#include "common/ast/ast_impl.h" #include "common/ast/expr.h" #include "common/casting.h" #include "common/expr.h" diff --git a/extensions/BUILD b/extensions/BUILD index a6b9a0990..6ae227f68 100644 --- a/extensions/BUILD +++ b/extensions/BUILD @@ -322,7 +322,6 @@ cc_library( "//common:native_type", "//common:type", "//common:value", - "//common/ast:ast_impl", "//eval/compiler:flat_expr_builder", "//eval/compiler:flat_expr_builder_extensions", "//eval/eval:attribute_trail", diff --git a/extensions/select_optimization.cc b/extensions/select_optimization.cc index 30fe40355..d9035077a 100644 --- a/extensions/select_optimization.cc +++ b/extensions/select_optimization.cc @@ -37,7 +37,6 @@ #include "base/attribute.h" #include "base/builtins.h" #include "common/ast.h" -#include "common/ast/ast_impl.h" #include "common/ast_rewrite.h" #include "common/casting.h" #include "common/constant.h" diff --git a/parser/BUILD b/parser/BUILD index 08ae823a5..63a6918c0 100644 --- a/parser/BUILD +++ b/parser/BUILD @@ -43,7 +43,6 @@ cc_library( "//common:expr_factory", "//common:operators", "//common:source", - "//common/ast:ast_impl", "//common/ast:expr", "//common/ast:expr_proto", "//common/ast:source_info_proto", @@ -185,7 +184,6 @@ cc_test( "//common:constant", "//common:expr", "//common:source", - "//common/ast:ast_impl", "//internal:testing", "//testutil:expr_printer", "@com_google_absl//absl/algorithm:container", @@ -210,7 +208,6 @@ cc_test( "//common:constant", "//common:expr", "//common:source", - "//common/ast:ast_impl", "//internal:benchmark", "//internal:testing", "//testutil:expr_printer", diff --git a/parser/parser.cc b/parser/parser.cc index 98f10a300..9f2cec0d9 100644 --- a/parser/parser.cc +++ b/parser/parser.cc @@ -54,7 +54,6 @@ #include "absl/types/variant.h" #include "antlr4-runtime.h" #include "common/ast.h" -#include "common/ast/ast_impl.h" #include "common/ast/expr.h" #include "common/ast/expr_proto.h" #include "common/ast/source_info_proto.h" @@ -1716,8 +1715,8 @@ class ParserImpl : public cel::Parser { const cel::Source& source) const override { CEL_ASSIGN_OR_RETURN(auto parse_result, ParseImpl(source, macro_registry_, options_)); - return std::make_unique( - std::move(parse_result.expr), std::move(parse_result.source_info)); + return std::make_unique(std::move(parse_result.expr), + std::move(parse_result.source_info)); } private: diff --git a/parser/parser_test.cc b/parser/parser_test.cc index e28030cca..3865476ee 100644 --- a/parser/parser_test.cc +++ b/parser/parser_test.cc @@ -30,7 +30,6 @@ #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "common/ast/ast_impl.h" #include "common/constant.h" #include "common/expr.h" #include "common/source.h" diff --git a/testutil/BUILD b/testutil/BUILD index 6fd1a1a9c..bb31ea02e 100644 --- a/testutil/BUILD +++ b/testutil/BUILD @@ -70,7 +70,6 @@ cc_library( ":expr_printer", "//common:ast", "//common:expr", - "//common/ast:ast_impl", "//common/ast:expr", "//extensions/protobuf:ast_converters", "@com_google_absl//absl/strings", @@ -83,7 +82,7 @@ cc_test( srcs = ["baseline_tests_test.cc"], deps = [ ":baseline_tests", - "//common/ast:ast_impl", + "//common:ast", "//common/ast:expr", "//internal:testing", "@com_google_protobuf//:protobuf", diff --git a/testutil/baseline_tests_test.cc b/testutil/baseline_tests_test.cc index 3c7f00cb5..13fcfab1b 100644 --- a/testutil/baseline_tests_test.cc +++ b/testutil/baseline_tests_test.cc @@ -8,7 +8,7 @@ // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or astied. // See the License for the specific language governing permissions and // limitations under the License. @@ -17,7 +17,7 @@ #include #include -#include "common/ast/ast_impl.h" +#include "common/ast.h" #include "common/ast/expr.h" #include "internal/testing.h" #include "google/protobuf/text_format.h" @@ -25,65 +25,62 @@ namespace cel::test { namespace { -using ::cel::ast_internal::AstImpl; using ::cel::expr::CheckedExpr; -using AstType = ast_internal::Type; - TEST(FormatBaselineAst, Basic) { - AstImpl impl; - impl.mutable_root_expr().mutable_ident_expr().set_name("foo"); - impl.mutable_root_expr().set_id(1); - impl.mutable_type_map()[1] = AstType(ast_internal::PrimitiveType::kInt64); - impl.mutable_reference_map()[1].set_name("foo"); + Ast ast; + ast.mutable_root_expr().mutable_ident_expr().set_name("foo"); + ast.mutable_root_expr().set_id(1); + ast.mutable_type_map()[1] = TypeSpec(ast_internal::PrimitiveType::kInt64); + ast.mutable_reference_map()[1].set_name("foo"); - EXPECT_EQ(FormatBaselineAst(impl), "foo~int^foo"); + EXPECT_EQ(FormatBaselineAst(ast), "foo~int^foo"); } TEST(FormatBaselineAst, NoType) { - AstImpl impl; - impl.mutable_root_expr().mutable_ident_expr().set_name("foo"); - impl.mutable_root_expr().set_id(1); - impl.mutable_reference_map()[1].set_name("foo"); + Ast ast; + ast.mutable_root_expr().mutable_ident_expr().set_name("foo"); + ast.mutable_root_expr().set_id(1); + ast.mutable_reference_map()[1].set_name("foo"); - EXPECT_EQ(FormatBaselineAst(impl), "foo^foo"); + EXPECT_EQ(FormatBaselineAst(ast), "foo^foo"); } TEST(FormatBaselineAst, NoReference) { - AstImpl impl; - impl.mutable_root_expr().mutable_ident_expr().set_name("foo"); - impl.mutable_root_expr().set_id(1); - impl.mutable_type_map()[1] = AstType(ast_internal::PrimitiveType::kInt64); + Ast ast; + ast.mutable_root_expr().mutable_ident_expr().set_name("foo"); + ast.mutable_root_expr().set_id(1); + ast.mutable_type_map()[1] = TypeSpec(ast_internal::PrimitiveType::kInt64); - EXPECT_EQ(FormatBaselineAst(impl), "foo~int"); + EXPECT_EQ(FormatBaselineAst(ast), "foo~int"); } TEST(FormatBaselineAst, MutlipleReferences) { - AstImpl impl; - impl.mutable_root_expr().mutable_call_expr().set_function("_+_"); - impl.mutable_root_expr().set_id(1); - impl.mutable_type_map()[1] = AstType(ast_internal::DynamicType()); - impl.mutable_reference_map()[1].mutable_overload_id().push_back( + Ast ast; + ast.mutable_root_expr().mutable_call_expr().set_function("_+_"); + ast.mutable_root_expr().set_id(1); + ast.mutable_type_map()[1] = TypeSpec(ast_internal::DynamicType()); + ast.mutable_reference_map()[1].mutable_overload_id().push_back( "add_timestamp_duration"); - impl.mutable_reference_map()[1].mutable_overload_id().push_back( + ast.mutable_reference_map()[1].mutable_overload_id().push_back( "add_duration_duration"); { - auto& arg1 = impl.mutable_root_expr().mutable_call_expr().add_args(); + auto& arg1 = ast.mutable_root_expr().mutable_call_expr().add_args(); arg1.mutable_ident_expr().set_name("a"); arg1.set_id(2); - impl.mutable_type_map()[2] = AstType(ast_internal::DynamicType()); - impl.mutable_reference_map()[2].set_name("a"); + ast.mutable_type_map()[2] = TypeSpec(ast_internal::DynamicType()); + ast.mutable_reference_map()[2].set_name("a"); } { - auto& arg2 = impl.mutable_root_expr().mutable_call_expr().add_args(); + auto& arg2 = ast.mutable_root_expr().mutable_call_expr().add_args(); arg2.mutable_ident_expr().set_name("b"); arg2.set_id(3); - impl.mutable_type_map()[3] = - AstType(ast_internal::WellKnownType::kDuration); - impl.mutable_reference_map()[3].set_name("b"); + ast.mutable_type_map()[3] = + TypeSpec(ast_internal::WellKnownType::kDuration); + ast.mutable_reference_map()[3].set_name("b"); } - EXPECT_EQ(FormatBaselineAst(impl), + EXPECT_EQ(FormatBaselineAst(ast), "_+_(\n" " a~dyn^a,\n" " b~google.protobuf.Duration^b\n" @@ -146,75 +143,75 @@ TEST(FormatBaselineCheckedExpr, MutlipleReferences) { } struct TestCase { - AstType type; + TypeSpec type; std::string expected_string; }; -class FormatBaselineAstTypeTest : public testing::TestWithParam {}; +class FormatBaselineTypeSpecTest : public testing::TestWithParam {}; -TEST_P(FormatBaselineAstTypeTest, Runner) { - AstImpl impl; - impl.mutable_root_expr().set_id(1); - impl.mutable_root_expr().mutable_ident_expr().set_name("x"); - impl.mutable_type_map()[1] = GetParam().type; +TEST_P(FormatBaselineTypeSpecTest, Runner) { + Ast ast; + ast.mutable_root_expr().set_id(1); + ast.mutable_root_expr().mutable_ident_expr().set_name("x"); + ast.mutable_type_map()[1] = GetParam().type; - EXPECT_EQ(FormatBaselineAst(impl), GetParam().expected_string); + EXPECT_EQ(FormatBaselineAst(ast), GetParam().expected_string); } INSTANTIATE_TEST_SUITE_P( - Types, FormatBaselineAstTypeTest, + Types, FormatBaselineTypeSpecTest, ::testing::Values( - TestCase{AstType(ast_internal::PrimitiveType::kBool), "x~bool"}, - TestCase{AstType(ast_internal::PrimitiveType::kInt64), "x~int"}, - TestCase{AstType(ast_internal::PrimitiveType::kUint64), "x~uint"}, - TestCase{AstType(ast_internal::PrimitiveType::kDouble), "x~double"}, - TestCase{AstType(ast_internal::PrimitiveType::kString), "x~string"}, - TestCase{AstType(ast_internal::PrimitiveType::kBytes), "x~bytes"}, - TestCase{AstType(ast_internal::PrimitiveTypeWrapper( + TestCase{TypeSpec(ast_internal::PrimitiveType::kBool), "x~bool"}, + TestCase{TypeSpec(ast_internal::PrimitiveType::kInt64), "x~int"}, + TestCase{TypeSpec(ast_internal::PrimitiveType::kUint64), "x~uint"}, + TestCase{TypeSpec(ast_internal::PrimitiveType::kDouble), "x~double"}, + TestCase{TypeSpec(ast_internal::PrimitiveType::kString), "x~string"}, + TestCase{TypeSpec(ast_internal::PrimitiveType::kBytes), "x~bytes"}, + TestCase{TypeSpec(ast_internal::PrimitiveTypeWrapper( ast_internal::PrimitiveType::kBool)), "x~wrapper(bool)"}, - TestCase{AstType(ast_internal::PrimitiveTypeWrapper( + TestCase{TypeSpec(ast_internal::PrimitiveTypeWrapper( ast_internal::PrimitiveType::kInt64)), "x~wrapper(int)"}, - TestCase{AstType(ast_internal::PrimitiveTypeWrapper( + TestCase{TypeSpec(ast_internal::PrimitiveTypeWrapper( ast_internal::PrimitiveType::kUint64)), "x~wrapper(uint)"}, - TestCase{AstType(ast_internal::PrimitiveTypeWrapper( + TestCase{TypeSpec(ast_internal::PrimitiveTypeWrapper( ast_internal::PrimitiveType::kDouble)), "x~wrapper(double)"}, - TestCase{AstType(ast_internal::PrimitiveTypeWrapper( + TestCase{TypeSpec(ast_internal::PrimitiveTypeWrapper( ast_internal::PrimitiveType::kString)), "x~wrapper(string)"}, - TestCase{AstType(ast_internal::PrimitiveTypeWrapper( + TestCase{TypeSpec(ast_internal::PrimitiveTypeWrapper( ast_internal::PrimitiveType::kBytes)), "x~wrapper(bytes)"}, - TestCase{AstType(ast_internal::WellKnownType::kAny), + TestCase{TypeSpec(ast_internal::WellKnownType::kAny), "x~google.protobuf.Any"}, - TestCase{AstType(ast_internal::WellKnownType::kDuration), + TestCase{TypeSpec(ast_internal::WellKnownType::kDuration), "x~google.protobuf.Duration"}, - TestCase{AstType(ast_internal::WellKnownType::kTimestamp), + TestCase{TypeSpec(ast_internal::WellKnownType::kTimestamp), "x~google.protobuf.Timestamp"}, - TestCase{AstType(ast_internal::DynamicType()), "x~dyn"}, - TestCase{AstType(ast_internal::NullType()), "x~null"}, - TestCase{AstType(ast_internal::UnspecifiedType()), "x~"}, - TestCase{AstType(ast_internal::MessageType("com.example.Type")), + TestCase{TypeSpec(ast_internal::DynamicType()), "x~dyn"}, + TestCase{TypeSpec(ast_internal::NullType()), "x~null"}, + TestCase{TypeSpec(ast_internal::UnspecifiedType()), "x~"}, + TestCase{TypeSpec(ast_internal::MessageType("com.example.Type")), "x~com.example.Type"}, - TestCase{AstType(ast_internal::AbstractType( + TestCase{TypeSpec(ast_internal::AbstractType( "optional_type", - {AstType(ast_internal::PrimitiveType::kInt64)})), + {TypeSpec(ast_internal::PrimitiveType::kInt64)})), "x~optional_type(int)"}, - TestCase{AstType(std::make_unique()), "x~type"}, - TestCase{AstType(std::make_unique( + TestCase{TypeSpec(std::make_unique()), "x~type"}, + TestCase{TypeSpec(std::make_unique( ast_internal::PrimitiveType::kInt64)), "x~type(int)"}, - TestCase{AstType(ast_internal::ParamType("T")), "x~T"}, - TestCase{ - AstType(ast_internal::MapType( - std::make_unique(ast_internal::PrimitiveType::kString), - std::make_unique( - ast_internal::PrimitiveType::kString))), - "x~map(string, string)"}, - TestCase{AstType(ast_internal::ListType(std::make_unique( + TestCase{TypeSpec(ast_internal::ParamType("T")), "x~T"}, + TestCase{TypeSpec(ast_internal::MapType( + std::make_unique( + ast_internal::PrimitiveType::kString), + std::make_unique( + ast_internal::PrimitiveType::kString))), + "x~map(string, string)"}, + TestCase{TypeSpec(ast_internal::ListType(std::make_unique( ast_internal::PrimitiveType::kString))), "x~list(string)"}));