Swift: an unqualified call to an inherited or extension member resolves to an unrelated top-level function
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- swift, typescript
- Domain
- devtools
Research direction
Start in src/wiki-engine/code-knowledge/ast/call-resolver.ts at the bare-call fallback around line 113 and the receiver fallback around line 161; read how findSwiftModuleSymbol and localBindings are used. Reproduce the inherited and extension-member fixtures described in the issue, comparing the ast/walk.ts revisions mentioned for #847. Done means Swift fallback resolution no longer emits unrelated REFERENCES edges for inherited or extension members, including the receiver case.
Written by the indexing model from the issue text.
Description
An unqualified call inside a type is resolved against the module's top-level declarations when the
current file does not bind the name. That is wrong when the name is a member the type already has —
inherited from a superclass, or added by an extension: Swift resolves the call to that member, while the
fallback emits a REFERENCES edge to an unrelated top-level function.
1. Minimal reproduction
// Sources/App/Base.swift
class Base {
func work() -> Int { return 1 }
}
// Sources/App/Sub.swift
class Sub: Base {
func run() -> Int { return work() }
}
// Sources/App/Global.swift
func work() -> Int { return 2 }
Expected: no edge (or one to Base.swift, which the index does not model as a member).
Actual: Sub.swift -REFERENCES-> Global.swift, confidence INFERRED.
An extension declared in a third file behaves the same:
// Sources/App/Ext.swift
extension Sub {
func work() -> Int { return 3 }
}
2. Where it comes from
src/wiki-engine/code-knowledge/ast/call-resolver.ts:113 — the bare-call fallback — consults
findSwiftModuleSymbol, which only knows declarations the module index collected as top-level and
module-visible. Members are in neither set, so the top-level func work() is the only candidate and it wins.
The localBindings guard on the same line does not help: it suppresses names bound inside the calling
file, and a member declared in another file (or inherited) is not bound there.
3. Scope
Swift only, and only for unqualified calls the same-file and import lookups leave unresolved. Both the
callee fallback (:113) and the receiver fallback (:161) have the shape — a subclass method shadowing
a module-level class name behaves the same way.
4. Candidate directions
Resolving it needs information the AST index does not build today: declared supertypes per type, the set
of extensions per type, and member names per type. Directions worth weighing:
- index members per type, and carry the enclosing type's inherited/extension members onto the call site so
the existinglocalBindingsguard can cover them; - or restrict the bare-call fallback to names no type in the module declares as a member — cheaper, and in
the same "rather miss an edge than invent one" direction.
5. Relation to #847
Not introduced by #847. The graph is identical with and without that change: running this fixture against
both revisions of ast/walk.ts emits one REFERENCES edge either way. It is split out here because
#847's review pass surfaced it and it is out of scope there — that change replaces the local-shadowing
rule, whereas this is a missing piece of the module model rather than a defect in the rule.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 386
- Avg merge
- 19h 44m
- Merged PRs (30d)
- 320
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Tencent/teamai-cli
-
[bug] The index shrink guard blocks legitimate rebuilds, so recall returns resources the member no longer hasPossibly taken @SaulMoro claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Tencent/teamai-cli#1006 ·
Maintainers usually reply within 1 day
-
[bug] push places new skills, rules and agents without the active projectsPossibly taken @SaulMoro claimed this today. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Tencent/teamai-cli#1021 ·
Maintainers usually reply within 1 day
-
[bug] push --all skips an edited skill that pull kept after a project switchPossibly taken @SaulMoro claimed this today. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Tencent/teamai-cli#1020 ·
Maintainers usually reply within 1 day
-
[bug] several project scopes, no user scope: only one project's env block survives, and doctor fails in every other projectPossibly taken @SaulMoro claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 15/100
Tencent/teamai-cli#1018 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement help wanted
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Tencent/teamai-cli#1014 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in Tencent/teamai-cli
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openclaw/openclaw#168089 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
✨ enhancement needs-discussion
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
[Bug]: [MCP/CLI] Bare loopback IP addresses (127.0.0.1:port) and hosts with ports fail to navigate due to erroneous scheme inferencePossibly taken @alok-108 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/playwright#43263 ·
Maintainers usually reply within 1 day
-
area:studio type:security
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
enhancement good first issue Stellar Wave trivial
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
StellarCanary/ProtocolCanary-Action#331 ·
Maintainers usually reply within 1 day