Skip to content

Kotlin: destructuring references the wrong componentN overload #1064

Open

Description

@christoph-sg

Example

class Overload {
    fun component1(dummy: Int): Int = dummy
    operator fun component1(): String = "one"
}
fun use(o: Overload) {
    val (x) = o       // references component1().   ← wrong
    o.component1()    // references component1(+1). ← correct
}

Expected: Both lines reference the no-arg operator overload, Overload#component1(+1)..

Actual: The destructuring declaration references Overload#component1()., which is the dummy: Int overload.

Cause: KotlinAnalysisIndexer.kt only checks whether some member has that name, then builds a symbol without a disambiguator.

Fix: Resolve the actual componentN callable and get its symbol from the reference cache. This should also cover local and inherited members.

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