Skip to content

Kotlin: fully-qualified call expressions produce no calls edge (same-package control isolates the qualified form) #2550

Closed

Description

@thomasrengot-hub

Summary

A fully-qualified call — com.demo.a.BetaScreen(2) — produces no calls edge,
while the same call written against an import does. The resolver appears to
consider only the file's import list, so any call written in qualified form is
invisible to the graph.

Measured on a 541-file Kotlin codebase (Android app + Wear module): the
navigation entry point called 43 of its 65 screens in qualified form, so
explain/affected on that node reported 34% of the real fan-out. Rewriting
those 43 call sites as imports — no behaviour change, no code deleted — took
recall to 83% (the remaining 17% is a separate parse bug, filed separately).
105 qualified call sites across 54 files remain unresolved elsewhere in the repo.

This is not a Compose or lambda problem: it reproduces with plain top-level
functions and with an object member, and it is not about packages either —
the qualified form fails even when caller and callee share a package.

Reproduction

graphify 0.9.36, graphify extract src --code-only (no LLM, no API key).

// src/a/Lib.kt
package com.demo.a

fun AlphaScreen(x: Int) { println(x) }
fun BetaScreen(x: Int) { println(x) }
fun GammaScreen(x: Int) { println(x) }
fun DeltaScreen(x: Int) { println(x) }

object Helper { fun help(x: Int) { println(x) } }
// src/b/Nav.kt
package com.demo.b

import com.demo.a.AlphaScreen
import com.demo.a.GammaScreen

fun composable(route: String, body: () -> Unit) { body() }

fun NavGraph() {
    composable("alpha") { AlphaScreen(1) }              // plain import
    composable("beta")  { com.demo.a.BetaScreen(2) }    // qualified
    composable("gamma") { GammaScreen(3) }              // plain import
    composable("delta") { com.demo.a.DeltaScreen(4) }   // qualified
    com.demo.a.Helper.help(5)                           // qualified, object member
}
// src/b/Same.kt — caller in the SAME package as the callee
package com.demo.a

fun SamePackageCaller() {
    BetaScreen(9)                 // same package, no import needed
    com.demo.a.DeltaScreen(10)    // qualified, same package
}

Observed

All calls edges in the resulting graph:

b_nav_navgraph              -> b_nav_composable
b_nav_navgraph              -> a_lib_gammascreen        # import
b_nav_navgraph              -> a_lib_alphascreen        # import
b_same_samepackagecaller    -> a_lib_betascreen         # same package, unqualified

Expected

Three more edges:

b_nav_navgraph              -> a_lib_betascreen         # com.demo.a.BetaScreen(2)
b_nav_navgraph              -> a_lib_deltascreen        # com.demo.a.DeltaScreen(4)
b_same_samepackagecaller    -> a_lib_deltascreen        # com.demo.a.DeltaScreen(10)

The Helper.help(5) call produces no edge either.

The last pair is the useful control: BetaScreen(9) resolves and
com.demo.a.DeltaScreen(10) does not, from the same file, in the same package,
to functions declared side by side. The discriminator is purely the qualified
form of the call expression, not the location of the callee.

Suggested fix

When the callee is a navigation_expression / qualified path whose prefix is a
package name, resolve on the last identifier segment — the same key already used
for imported and same-package calls. That is strictly additive: today those call
sites yield no edge at all, so there is no edge to regress.

If a stricter behaviour is preferred, the prefix could be matched against the
callee's declared package before emitting, which would also avoid the
name-collision concern raised in #2460.

Why this is not one of the existing Kotlin issues

I checked the open Kotlin set before filing:

Environment

graphify 0.9.36 · tree-sitter 0.25.2 · tree-sitter-kotlin 1.1.0 · Python 3.11 ·
Linux · extract --code-only (AST only).

Activity

  1. safishamsi commented on Aug 8, 2026

    @safishamsi
    Member

    Fixed in v0.9.37. A fully-qualified call such as com.example.Foo.bar() now flattens the navigation chain and produces a calls edge (resolved against the callee package/type). Thanks.

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