3232 * fields of its own struct declaration and the methods of its own interface
3333 * declaration: nothing promoted through embedding.
3434 *
35- * Binding. The graph keeps one node per qualified name, Go method nodes have
36- * a FLAT name (<dir>.<Method>), and <dir> is the directory, not the package
37- * clause: functions, methods of every receiver, types and values of one name,
38- * in every file of the directory, share one node, and the node is ONE of those
35+ * Binding. The graph keeps one node per qualified name, and <dir> is the
36+ * directory, not the package clause. Go method nodes are receiver-qualified
37+ * (<dir>.<Recv>.<Method>, #1913) and are found through their receiver only.
38+ * Functions, types and values of one name, in every file of the directory,
39+ * share one node <dir>.<name>, and the node is ONE of those
3940 * declarations (cbm_gbuf_upsert_node keeps the smallest file path, then the
4041 * last line). So a reference binds only when the node IS the entity it names:
4142 * the node's file is a file of the named package, the declaration that keeps
5960 * not), missing (a repository package that does not declare the name; an
6061 * import path inside a module without a package there), graph_gap (declared,
6162 * but the node is another declaration's or absent: block variables, later
62- * names of a declaration, embedded fields, methods that lost the flat name ;
63+ * names of a declaration, embedded fields;
6364 * also an undeclared name in a package with a parse error), test_only_target
6465 * (product code naming a declaration that only test files have), ambiguous
6566 * (several modules or packages fit; a name declared as two kinds; a name two
@@ -1063,7 +1064,7 @@ static void go_record_decl(go_index_t *ix, go_file_t *file, char **f, int nf) {
10631064 FIELD_FIELDS = 4 ,
10641065 IM_FIELDS = 3
10651066 };
1066- enum { F_OWNER = 2 , T_ALIAS = 3 , T_OWNER = 4 , V_OWNER = 2 , M_OWNER = 3 , FIELD_NODE = 3 };
1067+ enum { F_OWNER = 2 , T_ALIAS = 3 , T_OWNER = 4 , V_OWNER = 2 , FIELD_NODE = 3 };
10671068 char kind = f [0 ][0 ];
10681069 if (nf < IM_FIELDS || !go_name_ok (f [SKIP_ONE ])) {
10691070 return ;
@@ -1078,10 +1079,12 @@ static void go_record_decl(go_index_t *ix, go_file_t *file, char **f, int nf) {
10781079 go_add_sym (ix , file , GO_KIND_VALUE , f [SKIP_ONE ], NULL );
10791080 go_add_claim (ix , file , GO_KIND_VALUE , f [SKIP_ONE ], NULL , f [V_OWNER ]);
10801081 } else if (kind == 'M' && nf == M_FIELDS && go_name_ok (f [PAIR_LEN ])) {
1082+ /* #1913: a method is found through its receiver only; it claims no
1083+ * flat <dir>.<name> (its record says w `-`), so a type, function or
1084+ * value of the same name keeps that node. */
10811085 if (strcmp (f [SKIP_ONE ], "?" ) != 0 ) {
10821086 go_add_member (ix , file , GO_MEM_METHOD , f [SKIP_ONE ], f [PAIR_LEN ], true);
10831087 }
1084- go_add_claim (ix , file , GO_KIND_METHOD , f [PAIR_LEN ], f [SKIP_ONE ], f [M_OWNER ]);
10851088 } else if (kind == 'f' && nf == FIELD_FIELDS && go_name_ok (f [PAIR_LEN ])) {
10861089 go_add_member (ix , file , GO_MEM_FIELD , f [SKIP_ONE ], f [PAIR_LEN ], f [FIELD_NODE ][0 ] == '1' );
10871090 } else if (kind == 'm' && nf == IM_FIELDS && go_name_ok (f [PAIR_LEN ])) {
@@ -1342,9 +1345,9 @@ static const cbm_gbuf_node_t *go_member_node(const go_ctx_t *c, const go_pkg_t *
13421345 return (fm && (fm -> node_kinds & kind )) ? n : NULL ;
13431346}
13441347
1345- /* The node of the method `recv.name`: its receiver-qualified node, else the
1346- * flat node <dir>.<name> when the method is the one that kept it (the last
1347- * declaration of that name in the node's file) . */
1348+ /* The node of the method `recv.name`: its receiver-qualified node. The flat
1349+ * fallback below (the method that kept <dir>.<name>) is unreachable since
1350+ * #1913: no method record claims a flat name any more . */
13481351static const cbm_gbuf_node_t * go_method_node (const go_ctx_t * c , const go_pkg_t * pkg , go_str_t recv ,
13491352 go_str_t name ) {
13501353 const cbm_gbuf_node_t * qualified = go_member_node (c , pkg , GO_MEM_METHOD , recv , name );
0 commit comments