Skip to content

[Bug]: Kotlin calls to overloaded Java methods and from init blocks get no edge; inherited external calls bind to unrelated classes (follow-up to #4874) #4935

Closed

Description

@rafaelltlins

First of all, thank you for the very quick response on #4874! We upgraded to 0.9.100 the day it came out, and it solved a lot for us. In our private mixed Android project, graphify affected on a widely used Java class went from 0 of 36 Kotlin importers to 36 of 36, and imports and inheritance now resolve in both directions.

While validating the upgrade, we noticed a few remaining inconsistencies in calls edges from Kotlin. They are narrower than the original report, so we are opening a new issue rather than reopening #4874.

What we expected

Each call below should produce a calls edge to the method that is actually called, or no edge when the target is outside the repository:

  1. A Kotlin call to an overloaded Java method links to that method, as the equivalent Java call does.
  2. A Kotlin call inside an init block links to the called method.
  3. A call to a method inherited from an external class does not link to an unrelated class that happens to have a method with the same name.

What actually happened

  1. Overloaded Java method called from Kotlin: no edge is created. The non-overloaded method in the same class resolves from the same Kotlin file, and Java callers resolve in both cases.
  2. Call inside a Kotlin init block: no edge is created. The class has no node for the init block, so the call has no source to attach to. This may be related to Kotlin: calls in a class property initializer are never collected — only function bodies are walked (DI-container shape invisible) #2565, which covered property initializers.
  3. Inherited external method: KotlinScreen.title() calls getString inherited from android.app.Activity, but gets an INFERRED calls edge to the unrelated Prefs.getString(). This one may have a different cause from the other two, so please feel free to split it out.

graphify affected depends on these edges, so case 1 and case 2 silently omit callers, and case 3 lists callers that are not real.

Steps to reproduce

Tested on a clean folder with 0.9.100:

# src/com/example/util/Logger.java
package com.example.util;
public class Logger {
    public static int single(String tag) { return 0; }
    public static int overloaded(String tag) { return 0; }
    public static int overloaded(String tag, String msg) { return 0; }
}

# src/com/example/util/Prefs.java
package com.example.util;
public class Prefs {
    public String getString(String key) { return key; }
}

# src/com/example/app/JavaCaller.java
package com.example.app;
import com.example.util.Logger;
public class JavaCaller {
    public void callSingle() { Logger.single("a"); }
    public void callOverloaded() { Logger.overloaded("a"); }
}

# src/com/example/app/KotlinCaller.kt
package com.example.app
import com.example.util.Logger
class KotlinCaller {
    fun callSingle() { Logger.single("a") }
    fun callOverloaded() { Logger.overloaded("a") }
}

# src/com/example/app/KotlinInit.kt
package com.example.app
import com.example.util.Logger
class KotlinInit {
    init { Logger.single("a") }
}

# src/com/example/app/KotlinScreen.kt
package com.example.app
import android.app.Activity
class KotlinScreen : Activity() {
    fun title(): String = getString(1)
}

graphify update .
# then list the edges with relation "calls" in graphify-out/graph.json

Graph output

All calls edges in graph.json:

JavaCaller.java   .callOverloaded() -> Logger.java .overloaded() [EXTRACTED]
JavaCaller.java   .callSingle()     -> Logger.java .single()     [EXTRACTED]
KotlinCaller.kt   .callSingle()     -> Logger.java .single()     [EXTRACTED]
KotlinScreen.kt   .title()          -> Prefs.java  .getString()  [INFERRED]   (unrelated class)

Missing:
KotlinCaller.kt   .callOverloaded() -> Logger.java .overloaded()
KotlinInit.kt     (init block)      -> Logger.java .single()

Impact on a real project

In our project, 38 Kotlin files call a Java logging class whose main methods are overloaded, and the graph links only 1 of them. The one that links is a call to a non-overloaded method. We also see 121 INFERRED Kotlin calls to one Java class's getString(), which look like case 3, although we have not checked each one.

For now, we keep confirming callers with git grep, which works fine as a workaround.

Environment

  • Graphify version: 0.9.100
  • Operating system: Windows
  • Python: 3.14
  • Installation method: uv tool install
  • No provider API keys set

Thanks again for the great work and for how quickly you handled the previous report!

Activity

  1. github-actions commented on Nov 1, 2026

    @github-actions

    Thanks for opening this issue, @rafaelltlins. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Nov 3, 2026

    @safishamsi
    Member

    Fixed in 0.9.102 (published to PyPI) via #4956. Kotlin overloaded calls and init-block calls resolve, and a bare call no longer binds to a class the caller cannot reach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions