Open BoD opened 1 month ago
With 2.0.20-1.0.25.
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.
KSClassDeclaration.getAllFunctions()
c, a, b
a, b, c
Removing or renaming the c val makes the order correct again.
c
This only happens with ksp.useKSP2=true.
ksp.useKSP2=true
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>]
w: [ksp] all functions:[a, b, c, equals, hashCode, toString, <init>]
Actual: w: [ksp] all functions:[c, a, b, equals, hashCode, toString, <init>]
w: [ksp] all functions:[c, a, b, equals, hashCode, toString, <init>]
Have you tried Resolver.getDeclarationsInSourceOrder?
This seemed promising, but surprisingly, I still have the wrong order with getDeclarationsInSourceOrder. I've updated my repro project here
getDeclarationsInSourceOrder
With
2.0.20-1.0.25
.Given a class like this:
KSClassDeclaration.getAllFunctions()
will returnc, a, b
, instead ofa, b, c
.Removing or renaming the
c
val makes the order correct again.This only happens with
ksp.useKSP2=true
.Repro steps
Expected:
w: [ksp] all functions:[a, b, c, equals, hashCode, toString, <init>]
Actual:
w: [ksp] all functions:[c, a, b, equals, hashCode, toString, <init>]