Repository navigation
Conversation
…st test modules
Java
- `super.m()` keeps its receiver (the kernel names it bare `m`), so it resolves in
the ancestors instead of binding to the caller's own override.
- Class and method type parameters (`<T>`) become TypeParam bindings, so `T` no
longer links to an enum constant named `T`.
- One FQN in several source roots (guava/, android/guava/) resolves to the copy
nearest the referencing file by directory distance: same-package lookup,
imports and equal-qname global ties.
- A supertype clause cannot name the declaring class's own nested type.
All languages
- `let rt = rt();` / `copy = self.copy()`: a call is not shadowed by the local its
own line declares (an earlier binding, such as a parameter, still is). Swift's
existing rule is unchanged.
- In Rust, Java/Kotlin and Go a name-only guess never targets the caller itself
(`std.sync_all()` inside `File::sync_all`).
Rust
- Inline `mod support { pub mod panic; }` in a test crate root maps to
tests/support/panic.rs.
ENGINE_VERSION 11 -> 12.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
中文说明与实验证据这条评论用中文补充说明每个改动修的是什么,并附上真实项目上的原始终端输出(同一份源码分别用 main 和本分支建索引,再用 实验环境
1. Java
|
| 项目 | 指标 | main | 本分支 |
|---|---|---|---|
| express | 全图 | IDENTICAL | IDENTICAL |
| gin | 全图 | IDENTICAL | IDENTICAL |
| django | calls R / 全图 R | 76.51% / 90.76% | 76.55% / 90.77% |
| tokio | calls R / P* | 63.55% / 79.73% | 65.17% / 80.10% |
| commons-lang | references P | 78.49% | 94.49% |
| commons-lang | 全图 P | 84.31% | 86.25% |
| Guava(折叠) | references P | 81.90% | 89.15% |
| Guava(折叠) | calls R / 全图 R | 91.05% / 94.36% | 91.68% / 94.83% |
原始输出(compare 脚本 + db_digest)
$ db_digest.py express.main.sqlite express.br.sqlite → IDENTICAL
$ db_digest.py gin.main.sqlite gin.br.sqlite → IDENTICAL
$ compare.py django.main.sqlite django/.codegraph/codegraph.db
kind cgr up both P R
calls 48252 54328 41569 86.15% 76.51%
ALL 189560 192833 175014 92.33% 90.76%
$ compare.py django.br.sqlite django/.codegraph/codegraph.db
calls 48277 54328 41586 86.14% 76.55%
ALL 189586 192833 175031 92.32% 90.77%
$ compare.py tokio.main.sqlite tokio/.codegraph/codegraph.db
calls 14786 12729 8089 54.71% 63.55%
ALL 43467 35324 29342 67.50% 83.07%
[calls] P*= 79.73% R= 63.55% labeled=10146 extra-unlabeled=4640
$ compare.py tokio.br.sqlite tokio/.codegraph/codegraph.db
calls 15001 12729 8295 55.30% 65.17%
ALL 43704 35324 29549 67.61% 83.65%
[calls] P*= 80.10% R= 65.17% labeled=10356 extra-unlabeled=4645
$ compare.py commons-lang.main.sqlite commons-lang/.codegraph/codegraph.db
calls 37832 36323 28753 76.00% 79.16%
references 9643 7938 7569 78.49% 95.35%
ALL 73403 69835 61889 84.31% 88.62%
$ compare.py commons-lang.br.sqlite commons-lang/.codegraph/codegraph.db
calls 37811 36323 28751 76.04% 79.15%
references 8010 7938 7569 94.49% 95.35%
ALL 71749 69835 61887 86.25% 88.62%
$ compare.py guava.main.sqlite guava/.codegraph/codegraph.db --fold android/
calls 142722 137150 124876 87.50% 91.05%
references 35743 32719 29272 81.90% 89.46%
ALL 351161 335536 316599 90.16% 94.36%
$ compare.py guava.br.sqlite guava/.codegraph/codegraph.db --fold android/
calls 146578 137150 125740 85.78% 91.68%
references 33366 32719 29745 89.15% 90.91%
ALL 352868 335536 318204 90.18% 94.83%
Guava 的 calls P 下降主要来自新增的 super.x() 父类边和挪回 guava/ 的边,上游没有对应标注,计为"额外边"。
测试与增量一致性
$ cargo test --release --locked -p cg-resolve --test resolve_e2e -- java_overloads java_duplicate rust_inline # 本分支
test java_overloads_fields_super_and_type_parameters ... ok
test rust_inline_test_modules_self_init_calls_and_guesses ... ok
test java_duplicate_source_roots_resolve_within_their_own_root ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 59 filtered out; finished in 0.04s
$ (同样 3 个测试放到 main faf5dea 上)
test java_overloads_fields_super_and_type_parameters ... FAILED
test rust_inline_test_modules_self_init_calls_and_guesses ... FAILED
test java_duplicate_source_roots_resolve_within_their_own_root ... FAILED
test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 59 filtered out; finished in 0.04s
$ cargo test --release --locked --workspace # 汇总
passed 397 failed 0 ignored 1
$ cgr bench sync tokio --edits 100 --seed 1 --verify --json
{"edits": 100, "deltaSyncs": 82, "fullRebuilds": 18, "incrementalEqualsFull": true}
另外 django 随机编辑 ×50 增量 = 全量;Java 手工改动(让 super 目标多出一个 override、删除再恢复 android/ 下的副本)增量 = 全量。cgr bench sync 目前没有 .java 的改名规则,所以 Java 只能手工验证。
复现方式
# 两个版本分别构建
git checkout faf5dea && cargo build --release --locked -p cgr && cp target/release/cgr /tmp/cgr-main
git checkout fix/java-rust-resolution-precision && cargo build --release --locked -p cgr
# 例:commons-lang
git clone https://github.com/apache/commons-lang && cd commons-lang && git checkout c833cc1
/tmp/cgr-main index . && /tmp/cgr-main callees setUseClassName --file src/main/java/org/apache/commons/lang3/builder/StandardToStringStyle.java
<branch>/target/release/cgr index . && <branch>/target/release/cgr callees setUseClassName --file src/main/java/org/apache/commons/lang3/builder/StandardToStringStyle.java如果需要,我可以把对比脚本(compare.py 等)整理后放进 scripts/。
Summary
Resolver fixes found by indexing two large Java projects (Apache commons-lang, 631 files; Guava, 3,281 files with a duplicated
android/source tree) and by re-sampling Tokio misses against upstream. Each fix targets a concrete wrong or missing edge class; Express and Gin graphs are unchanged.Java
super.m()keeps its receiver. The kernel names it barem, so it bound to the caller's own override (fake recursion). The Java facts now restoresuper.mthrough the existingcall_namespath, and the call resolves in the ancestors.<T>) becomeTypeParambindings, reusing the existing Rust mechanism. Before,Tresolved to any enum constant namedT(commons-lang's test enumTooMany { T, E, R, ... }received 1,614referencesedges).guava-testsandguavalinked intoandroid/guava(36k call edges), althoughguava-tests/pom.xmldepends on the rootguavamodule.class CompareToBuilder implements Builder<Integer>with a nestedBuilder).All languages
let rt = rt();/copy = self.copy(): a call is not shadowed by the local its own line declares when that local is initialised by a call of the same name; an earlier binding (e.g. a callable parameter indefault = default()) still applies. This generalises the existing Swift-onlyswift_self_init, which is unchanged.global-name) guess never targets the caller itself, e.g.std.sync_all()inside tokio'sFile::sync_all. Dynamic languages are excluded because they really recurse through untyped children (Djangochild.relabel_aliases(...)).Rust
mod support { pub mod panic; }in a test crate root maps totests/support/panic.rs(35 Tokio integration tests use this).ENGINE_VERSION11 → 12.Results (main
faf5dea→ this branch)Same repositories, same upstream oracle (codegraph 1.6.2). Guava targets are folded across
android/(matched on path, kind and qualified name) so the copy choice itself is not scored.super.x()self-bound 126 → 0; self-loop calls 205 → 79guava-tests→androidcall edges 36,395 → 0;super.x()self-bound 1,154 → 0copy = self.copy(),EndToken = EndToken())Validation
-D warnings) clean; only the changed files were formatted.bench sync×100, Django ×50, plus targeted Java edits (asupertarget gaining an override; deleting and restoring anandroid/copy).Not in this PR / notes for review
call_args.T.javato commons-lang leaves the incremental index different from a full rebuild (status of a fewContextedExceptionTestrefs). Reproduces identically with main's binary.cgr bench synchas no rename rule for.java, so Java incremental checks were manual.TypeUtils.toString(x)to a nested class'stoString). Agreement numbers above should be read together with the semantic checks, not as ground truth.🤖 Generated with Claude Code