Repository navigation
Description
Environment
- graphify 0.9.37 (PyPI
graphifyy), macOS 15, Python 3.14 graphify extract <dir> --code-only --no-cluster— local AST only, no LLM, no API key
Summary
Calls written in a class property initializer are never collected. The call pass appears to
descend only into function bodies, so class C { val x = Foo(1) } produces no edge from C to
Foo at all — no calls, no references, nothing.
This is not about constructors and not about packages; both isolate out below. It is purely the
position of the call.
It matters more than it looks, because a property initializer is the standard shape for
dependency-injection roots and for Kotlin singletons/containers. On a multi-module KMP repo the
container that constructs ~15 repositories has zero outgoing edges to any of them, so
affected on any of those repositories cannot reach the object that owns them.
Reproduction
Four files, one package, no build system.
// src/Lib.kt
package demo.repo
class Settings(val n: Int)
fun helper(x: Int) = x// src/PropInit.kt
package demo.repo
class PropInit {
val a = Settings(1) // constructor call in a property initializer
val b = helper(2) // plain function call in a property initializer
}// src/FnBody.kt
package demo.repo
class FnBody {
fun go() {
val a = Settings(3) // identical call, inside a function body
val b = helper(4)
}
}$ graphify extract . --code-only --no-cluster
$ graphify affected "Settings" --depth 3
- .go() [calls] src/FnBody.kt:L5
$ graphify affected "helper()" --depth 3
- .go() [calls] src/FnBody.kt:L6
FnBody resolves for both call kinds. PropInit appears in neither result, for either kind.
Isolation
| Call site | Constructor Settings(n) |
Function helper(n) |
|---|---|---|
Function body (fun go() { … }) |
calls ✅ |
calls ✅ |
Expression body (fun make() = Settings(n)) |
calls ✅ |
— |
Class property initializer (val x = …) |
none ❌ | none ❌ |
So constructors are fine, and same-package resolution is fine. Only the property-initializer
position fails.
One adjacent detail worth noting: when the enclosing function carries an explicit return type,
the edge that appears comes from the type annotation, not from the call.
class Annotated { fun make(): Settings = Settings(1) } // -> references (from the annotation)
class Inferred { fun make() = Settings(2) } // -> calls (from the call)Both call Settings(…) identically, and they produce different relations. That suggests the
annotation path and the call path are independent, and only the latter is missing for property
initializers.
Why this isn't #2550 or #2526
- Kotlin: fully-qualified call expressions produce no calls edge (same-package control isolates the qualified form) #2550 was the fully-qualified call form (
com.demo.a.Beta(2)); every call here is unqualified. - Kotlin: _KOTLIN_CONFIG declares node type
import_header, bundled grammar emitsimport— every Kotlin imports edge is silently dropped (45% -> 95% dep recall with a 2-line fix) #2526 was Kotlin imports being dropped; that fix landed in 0.9.37 and is working — cross-package
property initializers now at least surface animportsedge, which masks this bug. Same-package
code has no import to mask it, so the relationship disappears completely.
Effect at scale
On a private multi-module Kotlin/Swift KMP repo (0.9.37, imports fix included): the DI container
class has 20 outgoing edges and none to the repository it constructs on the line
val settings = SettingsRepository(keyValueStore, analytics, blobStore). Reverse traversal from
that repository returns 18 files and omits its own owner. The file parses clean — no ERROR nodes
from the bundled grammar — so this is not the parse issue from #2551.
Suggestion
Whatever walk collects call_expression for function_declaration bodies likely needs to run for
property_declaration initializers too (and probably class_body init blocks), attributing the
edge to the enclosing class rather than to an enclosing function. Happy to test a patch against
both the repro above and the larger repo.
Investigated and written with Claude Code (Claude Opus 5).
Activity
fix: JS/Kotlin/Swift/SQL extractor correctness batch; bump to 0.9.38 (#…
safishamsi commentedon Aug 9, 2026
Fixed in v0.9.38. Kotlin property initializers now seed call extraction: a class property (
val repo = createRepo()), aby lazy { ... }delegate, a companion-object property, and a top-level property initializer produce calls edges attributed to the enclosing class (or file), including fully-qualified calls (composing with #2550). A plain literal initializer produces no edge. Thanks for the report.fix: JS/Kotlin/Swift/SQL extractor correctness batch; bump to 0.9.38 (G…
feat(kernel): Kotlin native walker — all ten languages now gated
test(kotlin): cover companion members + incremental persistence (#1698 …
test(kotlin): pin the Kotlin/Java call edges that already resolve (Gr…
fix(kotlin): attribute calls inside an init block to the class (Graph…
test(kotlin): pin the Kotlin/Java call edges that already resolve (#4935
fix(kotlin): attribute calls inside an init block to the class (#4935)