Skip to content

fix(kotlin): emit implements edge for interface delegation (by)#1644

Closed
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/kotlin-interface-delegation-implements
Closed

fix(kotlin): emit implements edge for interface delegation (by)#1644
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/kotlin-interface-delegation-implements

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What it fixes

Kotlin interface delegation — class Foo : Bar by baz — emitted no edge, so the delegated interface Bar was silently dropped from the graph.

The delegation_specifier loop only handled constructor_invocation (→ inherits) and a bare user_type (→ implements) child. The by form produces an explicit_delegation node that wraps the user_type, so neither branch fired and no edge was emitted. Delegation is idiomatic Kotlin (the whole point of by).

Fix

Add an explicit_delegation branch in that loop: take its wrapped user_type child and emit the implements edge, leaving the existing generic type-argument recovery intact.

class LoggingList<T>(inner: MutableList<T>) : MutableList<T> by inner

now emits implements: LoggingList -> MutableList (and references: LoggingList -> T for the generic arg).

Test

  • tests/fixtures/sample.kt: added the delegation example above.
  • tests/test_languages.py: test_kotlin_interface_delegation_emits_implements asserts the implements edge.
  • pytest tests/test_languages.py -k kotlin → 9 passed (negative control without the fix fails on the missing edge).

class Foo : Bar by baz produced no edge because the delegation_specifier loop only handled constructor_invocation and bare user_type children; the by form wraps user_type in an explicit_delegation node. Add that branch so the implements edge (and generic-arg recovery) fires.
safishamsi added a commit that referenced this pull request Jul 4, 2026
…delegation)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

Merged into v8 as 9b04022, with your authorship preserved (ships in 0.9.6). Thanks @Synvoya.

Nice catch on the explicit_delegation wrapper — the by form fell between the constructor_invocation and bare user_type branches so the edge was dropped. Unwrapping to the inner user_type keeps generic-argument recovery working, and implements (not inherits) is the right relation for delegation. Fixture + test made review easy.

@safishamsi safishamsi closed this Jul 4, 2026
safishamsi added a commit that referenced this pull request Jul 4, 2026
19 fixes/features since 0.9.5. Highlights:
- Ruby: module/Struct.new/Class.new/Data.define container nodes (#1640) and
  constant-receiver singleton-call resolution (#1634) — Rails/Zeitwerk graphs
  now get real cross-file edges.
- Kill cross-language phantom imports_from edges from unresolved bare npm
  imports (#1638); harden semantic extraction against malformed LLM chunks
  (#1631); deterministic graph.json node/edge ordering for parallel semantic
  backends (#1632).
- Contributor extractor fixes: Apex interface multiple inheritance (#1645),
  Kotlin `by` delegation (#1644).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants