Skip to content

[KSP2] KSClassDeclaration.getAllFunctions() doesn't return functions in the order they're declared #2135

@BoD

Description

@BoD

With 2.0.20-1.0.25.

Given a class like this:

class MyClass(private val c: Int) {
  fun a(){}
  fun b(){}
  fun c(){}
}

KSClassDeclaration.getAllFunctions() will return c, a, b, instead of a, b, c.

Removing or renaming the c val makes the order correct again.

This only happens with ksp.useKSP2=true.

Repro steps

git clone https://github.com/BoD/repro-ksp-getAllFunctions-order
cd repro-ksp-getAllFunctions-order
./gradlew build

Expected:
w: [ksp] all functions:[a, b, c, equals, hashCode, toString, <init>]

Actual:
w: [ksp] all functions:[c, a, b, equals, hashCode, toString, <init>]

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