Dart: field access is bound to a same-named method of an unrelated class, fabricating CALLS edges (name-only fallback; cf. #1355, #2605, #2892)

未关闭
#3,074 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
dart
领域
devtools

调研方向

Start by reproducing with the minimal lib/field_vs_method.dart file from the issue after a clean index, then run the CALLS query on _send. Check that Holder.attach and Holder.detach produce fabricated edges to Api._send, while only go should remain. Related issues #1355, #2605, #2892 and #2121 describe the same name-only fallback, so read them first. Done when the query returns only go and get_code_snippet reports the same caller set.

由索引模型根据 Issue 内容生成。

描述

bug parsing/quality ux/behavior windows

Summary

For Dart, reading or null-calling a field whose name happens to match a method of another class produces a CALLS edge to that method. The graph gains calls that do not exist in the code: a private field _send of one class is bound to Api._send, a method of an unrelated class in the same file.

This is the Dart face of the name-only fallback binding already tracked for other languages — #1355 (general), #2605 (Rust, field receiver), #2892 (C#), #2121 (phantom callers) — and the same shape #2977 refused for member calls. Dart is still affected on 0.12.1.

Minimal repro (0.12.1, clean index, 22 Nov 2026)

lib/field_vs_method.dart:

class Api {
  Future<void> _send(String path) async {
    print(path);
  }

  Future<void> go() => _send('/real');     // the only real call
}

class Listener {
  Listener({this.onTick});
  final void Function()? onTick;
  void fire() { onTick?.call(); }
}

class Holder {
  Holder({this._send});
  final Listener? _send;                   // a FIELD, not a method
  void attach() { _send?.fire(); }          // reads the field; calls Listener.fire
  void detach() { _send?.fire(); }
}

Query:

MATCH (c)-[:CALLS]->(f) WHERE f.name = '_send'
RETURN c.name AS caller, c.file AS caller_file, c.start_line AS caller_line

Actual — 3 rows:

caller file line
go lib/field_vs_method.dart 6
attach lib/field_vs_method.dart 24
detach lib/field_vs_method.dart 28

Expected — 1 row (go). Holder.attach / Holder.detach never call Api._send; they read Holder._send, a Listener? field, and call Listener.fire.

get_code_snippet(qualified_name = "Api._send", include_neighbors = true) agrees with the bad edges: callers: 3, caller_names: attach, detach, go.

Same thing on a real Flutter app

In a ~5 kLoC Flutter project (ApiClient._send in lib/api/api_client.dart), the graph reports 7 callers of ApiClient._send where the code has 4. The three extras are:

  • lib/ui/orders/status_controller.dart — final SendController? _send; field, used as _send?.addListener(...), _send!.sending, _send?.removeListener(...);
  • lib/ui/settings/settings_screen.dart — the widget's own private method Future<void> _send() async { ... }, a different symbol entirely.

Interestingly, on that project the two sides of the server disagree: get_code_snippet reports callers: 4 (correct) while query_graph over CALLS returns 7 rows. On the minimal repro both report the inflated number, so the real-project discrepancy looks like a second, separate inconsistency between the snippet's caller count and the graph edges.

Why it matters

Impact analysis and trace_path on Dart read as if a widget's own _send and a controller's _send field flowed into the HTTP layer. Removing or changing ApiClient._send appears to affect unrelated UI code, and the inverse — a real caller hidden among fabricated ones — is not distinguishable by the consumer.

Environment

  • codebase-memory-mcp 0.12.1
  • Dart 3.14.0 / Flutter project and the standalone repro above
  • Windows Server 2019, clean (mode: clean) index
主要语言
C
星标
45.8k
派生
3.8k
平均合并
2 天 18 小时
30 天内合并 PR
108

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DeusData/codebase-memory-mcp 的其他 Issue

查看 DeusData/codebase-memory-mcp 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。