Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Merge origin/main into fix/go-init-qn

Martin Vogel7a9e6c628eda
diff --cc tests/test_go_lsp.c
index 900c3c882,b79101c07..1f0d58087
--- a/tests/test_go_lsp.c
+++ b/tests/test_go_lsp.c
@@@ -1378,6 -1378,127 +1378,127 @@@ TEST(golsp_crossfile_aliased_field_requ
PASS();
}
+ /* #2033: an identity alias declared in another file of the same package.
+ * `type FeatureSet = bitmap` lives in one file, `bitmap.Set` in a second, the
+ * call `reqs.Set` in a third, so none of it is in the calling file's AST and
+ * only the defs can carry the alias. A defined type (`type Defined bitmap`)
+ * must not inherit bitmap's methods. The decoy `other.Set` keeps a name-only
+ * match from passing. Both cross-file registries are checked: the per-file
+ * one and the prebuilt one shared by the parallel resolve. */
+ static CBMLSPDef go_crossfile_alias_defs[] = {
+ {.qualified_name = "test.main.bitmap",
+ .short_name = "bitmap",
+ .label = "Class",
+ .def_module_qn = "test.main"},
+ {.qualified_name = "test.main.bitmap.Set",
+ .short_name = "Set",
+ .label = "Method",
+ .def_module_qn = "test.main",
+ .receiver_type = "test.main.bitmap"},
+ {.qualified_name = "test.main.FeatureSet",
+ .short_name = "FeatureSet",
+ .label = "Type",
+ .def_module_qn = "test.main",
+ .alias_target = "bitmap"},
+ {.qualified_name = "test.main.Defined",
+ .short_name = "Defined",
+ .label = "Class",
+ .def_module_qn = "test.main"},
+ {.qualified_name = "test.main.Framework",
+ .short_name = "Framework",
+ .label = "Struct",
+ .def_module_qn = "test.main"},
+ {.qualified_name = "test.main.Framework.NewFeatureSet",
+ .short_name = "NewFeatureSet",
+ .label = "Method",
+ .def_module_qn = "test.main",
+ .receiver_type = "test.main.Framework",
+ .return_types = "FeatureSet"},
+ {.qualified_name = "test.main.Framework.NewDefined",
+ .short_name = "NewDefined",
+ .label = "Method",
+ .def_module_qn = "test.main",
+ .receiver_type = "test.main.Framework",
+ .return_types = "Defined"},
+ {.qualified_name = "test.main.other",
+ .short_name = "other",
+ .label = "Struct",
+ .def_module_qn = "test.main"},
+ {.qualified_name = "test.main.other.Set",
+ .short_name = "Set",
+ .label = "Method",
+ .def_module_qn = "test.main",
+ .receiver_type = "test.main.other"},
+ };
+
+ static const char *go_crossfile_alias_source = "package main\n\n"
+ "func useAlias(f *Framework) {\n"
+ "\treqs := f.NewFeatureSet()\n"
+ "\treqs.Set(3)\n}\n\n"
+ "func useDefined(f *Framework) {\n"
+ "\td := f.NewDefined()\n"
+ "\td.Set(3)\n}\n";
+
+ static int go_crossfile_alias_check(const CBMResolvedCallArray *out) {
+ int idx = find_resolved_arr_confident(out, "useAlias", ".Set");
+ if (idx < 0 || strcmp(out->items[idx].callee_qn, "test.main.bitmap.Set") != 0) {
+ printf(" resolved calls (%d):\n", out->count);
+ for (int i = 0; i < out->count; i++) {
+ const CBMResolvedCall *rc = &out->items[i];
+ printf(" %s -> %s [%s %.2f]\n", rc->caller_qn ? rc->caller_qn : "(null)",
+ rc->callee_qn ? rc->callee_qn : "(null)", rc->strategy ? rc->strategy : "(null)",
+ rc->confidence);
+ }
+ }
+ ASSERT_GTE(idx, 0);
+ ASSERT_STR_EQ(out->items[idx].callee_qn, "test.main.bitmap.Set");
+ /* Reached through alias_of, so the emitter reports it the way it reports
+ * a same-file alias today (lsp_embed_dispatch): typed, not a name guess. */
+ ASSERT_TRUE(strncmp(out->items[idx].strategy, "lsp_", 4) == 0);
+ ASSERT_TRUE(strcmp(out->items[idx].strategy, "lsp_unresolved") != 0);
+ ASSERT_TRUE(out->items[idx].confidence >= 0.9f);
+ /* A defined type has its own (empty) method set. */
+ ASSERT_EQ(find_resolved_arr_confident(out, "useDefined", "bitmap.Set"), -1);
+ return 0;
+ }
+
+ TEST(golsp_crossfile_type_alias_method) {
+ int n = (int)(sizeof(go_crossfile_alias_defs) / sizeof(go_crossfile_alias_defs[0]));
+ CBMArena arena;
+ cbm_arena_init(&arena);
+ CBMResolvedCallArray out = {0};
+
+ cbm_run_go_lsp_cross(&arena, go_crossfile_alias_source, (int)strlen(go_crossfile_alias_source),
- "test.main", go_crossfile_alias_defs, n, NULL, NULL, 0, NULL, &out);
++ "test.main", NULL, go_crossfile_alias_defs, n, NULL, NULL, 0, NULL, &out);
+ if (go_crossfile_alias_check(&out) != 0) {
+ cbm_arena_destroy(&arena);
+ return 1;
+ }
+
+ cbm_arena_destroy(&arena);
+ PASS();
+ }
+
+ TEST(golsp_crossfile_type_alias_method_prebuilt) {
+ int n = (int)(sizeof(go_crossfile_alias_defs) / sizeof(go_crossfile_alias_defs[0]));
+ CBMArena arena;
+ cbm_arena_init(&arena);
+ CBMResolvedCallArray out = {0};
+
+ CBMTypeRegistry *reg = cbm_go_build_cross_registry(&arena, go_crossfile_alias_defs, n);
+ ASSERT_NOT_NULL(reg);
+ cbm_run_go_lsp_cross_with_registry(&arena, go_crossfile_alias_source,
- (int)strlen(go_crossfile_alias_source), "test.main", reg,
- NULL, NULL, 0, NULL, &out);
++ (int)strlen(go_crossfile_alias_source), "test.main", NULL,
++ reg, NULL, NULL, 0, NULL, &out);
+ if (go_crossfile_alias_check(&out) != 0) {
+ cbm_arena_destroy(&arena);
+ return 1;
+ }
+
+ cbm_arena_destroy(&arena);
+ PASS();
+ }
+
TEST(golsp_crossfile_local_interface_single_impl) {
const char *source =
"package main\n\n"
diff --cc tests/test_pipeline.c
index ce60edf58,43226e046..b2c6a888a
--- a/tests/test_pipeline.c
+++ b/tests/test_pipeline.c
@@@ -29145,9 -28955,8 +29240,11 @@@ SUITE(pipeline)
RUN_TEST(pipeline_go_receiver_parallel_suppresses_weak_method_edge);
RUN_TEST(pipeline_go_multi_return_receiver_is_typed);
RUN_TEST(pipeline_go_multi_return_receiver_is_typed_parallel);
+ RUN_TEST(pipeline_go_multi_init_nodes_survive);
+ RUN_TEST(pipeline_go_init_lsp_edges_per_file);
+ RUN_TEST(pipeline_go_init_lsp_edges_per_file_parallel);
+ RUN_TEST(pipeline_go_crossfile_type_alias_method);
+ RUN_TEST(pipeline_go_crossfile_type_alias_method_parallel);
RUN_TEST(pipeline_go_rw_usage_never_cross_into_c);
RUN_TEST(pipeline_go_rw_usage_never_cross_into_c_parallel);
RUN_TEST(pipeline_rust_call_never_binds_another_language);