Skip to content

bug(parsers/kotlin): annotations with arguments are recorded as function calls #1602

Closed

Description

@Shashankss1205

Split out of #1595 (report 5 of 9) — filed by @rrodriguesNutrium, credit to them.

KOTLIN_QUERIES["calls"] (kotlin.py:24-30) captures (constructor_invocation). In the tree-sitter Kotlin grammar an annotation with arguments is annotation -> @ + constructor_invocation, so every such annotation is collected as a call from the annotated function:

@Preview(showBackground = true)
@Deprecated("old")
fun Foo() { realCall() }

function_calls for Foo yields Preview (line 3), Deprecated (line 4) and realCall (line 6).

Argument-less annotations (@Composable, @Test) are unaffected — no arguments means no constructor_invocation.

Consequences:

  • Phantom CALLS edges from any function carrying an annotation with arguments. On Android that is a large share of functions: @Preview(...), @Query(...), @Insert(...), @InstallIn(...), @SerialName(...).
  • A function whose name matches an annotation's simple name gains spurious inbound callers, which also makes it look alive to find_dead_code.
  • analyze call-chain / analyze callers traverse these edges, so the noise is user-visible.

Fix direction (untested, from the reporter): a constructor_invocation whose parent chain includes annotation/modifiers is an annotation, not a call — skipping those should filter them.

Activity

  1. github-actions commented on Aug 13, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  2. moved this from Backlog tasks to In progress in CGC Progress Boardon Aug 14, 2026
  3. added a commit that references this issue on Aug 18, 2026
  4. moved this from In progress to Done in CGC Progress Boardon Aug 18, 2026
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

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions