Skip to content

Kotlin AST extractor doesn't set parentClass on nested classes, inflating jvm-same-package-signals.ts's top-level declaration index #1114

Description

@alfhen

Noticed while implementing #1005 Phase 2 Item 1 (call-graph same-package tier). jvm-same-package-signals.ts's collectTopLevelDeclarations restricts to top-level class/interface declarations via !chunk.metadata.parentClass — same-package visibility only applies to top-level types, per JLS/Kotlin semantics.

The Kotlin AST extractor, however, doesn't currently set parentClass on a nested class's own chunk the way the Java extractor does. This means a Kotlin nested class (e.g. inside a sealed hierarchy or a companion-adjacent inner class) is currently indistinguishable from a real top-level declaration in jvm-same-package-signals.ts's index — it gets treated as eligible for G1'/G5 resolution when it structurally shouldn't be.

This is a real but small, out-of-scope-for-#1005-Phase-2 precision issue (not something the same-package tier's own logic can fix — it's upstream, in the Kotlin extractor itself). Filing to track it separately. Likely fix: audit KotlinSymbolExtractor (or wherever nested-class chunks are built) for parity with the Java extractor's parentClass assignment, then add a regression test to jvm-same-package-signals.test.ts asserting a Kotlin nested class is excluded from collectTopLevelDeclarations.

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