@@ -2705,6 +2705,27 @@ static const char **split_pipe_strings(CBMArena *a, const char *text) {
27052705 return idx > 0 ? arr : NULL ;
27062706}
27072707
2708+ /* QN of the type an identity alias `type A = B` names, for the def-driven
2709+ * cross-file registries (#2033). The per-file AST scan sets alias_of only for
2710+ * the file it walks, so an alias declared in another file of the package
2711+ * reaches a call only through here. Only a bare identifier is qualified (B
2712+ * declared in A's package); a qualified, pointer, composite or generic target
2713+ * stays NULL rather than guessed. */
2714+ static const char * go_alias_target_qn (CBMArena * arena , const char * target ,
2715+ const char * def_module_qn ) {
2716+ if (!target || !target [0 ] || !def_module_qn || !def_module_qn [0 ]) {
2717+ return NULL ;
2718+ }
2719+ for (const unsigned char * p = (const unsigned char * )target ; * p ; p ++ ) {
2720+ bool ident = (* p >= 'a' && * p <= 'z' ) || (* p >= 'A' && * p <= 'Z' ) ||
2721+ (* p >= '0' && * p <= '9' ) || * p == '_' || * p >= 0x80 ;
2722+ if (!ident ) {
2723+ return NULL ;
2724+ }
2725+ }
2726+ return cbm_arena_sprintf (arena , "%s.%s" , def_module_qn , target );
2727+ }
2728+
27082729// Helper: parse "|"-separated "name:type" field definitions and populate a registered type.
27092730// Format: "Binder:Binder|Name:string|Count:int"
27102731// type_text is resolved relative to def_module_qn.
@@ -3273,6 +3294,7 @@ void cbm_run_go_lsp_cross(CBMArena *arena, const char *source, int source_len,
32733294 if (rt .is_interface && d -> method_names_str && d -> method_names_str [0 ]) {
32743295 rt .method_names = split_pipe_strings (arena , d -> method_names_str );
32753296 }
3297+ rt .alias_of = go_alias_target_qn (arena , d -> alias_target , def_mod );
32763298
32773299 cbm_registry_add_type (& reg , rt );
32783300
@@ -3569,6 +3591,7 @@ CBMTypeRegistry *cbm_go_build_cross_registry(CBMArena *arena, CBMLSPDef *defs, i
35693591 if (rt .is_interface && d -> method_names_str && d -> method_names_str [0 ]) {
35703592 rt .method_names = split_pipe_strings (arena , d -> method_names_str );
35713593 }
3594+ rt .alias_of = go_alias_target_qn (arena , d -> alias_target , def_mod );
35723595 cbm_registry_add_type (reg , rt );
35733596 GO_NOTE_NEW_TYPES ();
35743597 if (d -> field_defs && d -> field_defs [0 ]) {
0 commit comments