Skip to content

Kotlin: SAM constructor calls don't reference the interface #1061

Open

Description

@christoph-sg

Example

fun interface Action { fun run() }
val action = Action { println("one") }
val runnable = Runnable { println("two") }

Expected: Action { … } references probe/Action# and Runnable { … } references java/lang/Runnable#.

Actual: Only method-like symbols are emitted: probe/Action(). and java/lang/Runnable().. Go-to-definition can't reach the interface.

Cause: SAM constructors fall through to the generic callable path in KotlinAnalysisIndexer.kt. The old FIR indexer handled FirDeclarationOrigin.SamConstructor by referencing the return class.

Fix: Handle KaSamConstructorSymbol and emit the interface symbol. Test both a Kotlin fun interface and a Java interface.

Activity

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