Skip to content

Commit

Permalink
Add support for basic function overload resolution. Follow-up will ad…
Browse files Browse the repository at this point in the history
…dress resolving parameterized types.

PiperOrigin-RevId: 669084859
  • Loading branch information
jnthntatum authored and copybara-github committed Sep 17, 2024
1 parent 4e8daf2 commit 697bac3
Show file tree
Hide file tree
Showing 8 changed files with 1,558 additions and 41 deletions.
46 changes: 46 additions & 0 deletions checker/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ cc_library(
srcs = ["type_checker_impl.cc"],
hdrs = ["type_checker_impl.h"],
deps = [
":builtins_arena",
":namespace_generator",
":type_check_env",
":type_inference_context",
"//base/ast_internal:ast_impl",
"//base/ast_internal:expr",
"//checker:type_check_issue",
Expand All @@ -113,18 +115,26 @@ cc_library(
"//common:ast_traverse",
"//common:ast_visitor",
"//common:ast_visitor_base",
"//common:constant",
"//common:decl",
"//common:expr",
"//common:source",
"//common:type",
"//common:type_kind",
"//internal:status_macros",
"@com_google_absl//absl/base:no_destructor",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:span",
"@com_google_protobuf//:protobuf",
],
)

Expand All @@ -144,8 +154,44 @@ cc_test(
"//common:type",
"//internal:status_macros",
"//internal:testing",
"@com_google_absl//absl/base:no_destructor",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:status_matchers",
"@com_google_absl//absl/strings",
"@com_google_cel_spec//proto/test/v1/proto3:test_all_types_cc_proto",
"@com_google_protobuf//:protobuf",
],
)

cc_library(
name = "type_inference_context",
srcs = ["type_inference_context.cc"],
hdrs = ["type_inference_context.h"],
deps = [
"//common:decl",
"//common:type",
"//common:type_kind",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:node_hash_map",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:span",
"@com_google_protobuf//:protobuf",
],
)

cc_test(
name = "type_inference_context_test",
srcs = ["type_inference_context_test.cc"],
deps = [
":type_inference_context",
"//common:type",
"//common:type_kind",
"//internal:testing",
"@com_google_protobuf//:protobuf",
],
)
3 changes: 2 additions & 1 deletion checker/internal/type_check_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class TypeCheckEnv {
}

// Inserts a function declaration into the environment of the current scope if
// is is not already present. Parent scopes are not searched.
// is is not already present. Parent scopes are not searched (allowing for
// shadowing).
//
// Returns true if the decl was inserted, false otherwise.
bool InsertFunctionIfAbsent(FunctionDecl decl) {
Expand Down
Loading

0 comments on commit 697bac3

Please # to comment.