google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.89k stars 274 forks source link

[KSP2] Property setter parameter name becomes `value` #1865

Closed kuanyingchou closed 2 months ago

kuanyingchou commented 6 months ago

In KSP2 the parameter name of property setters is value when the origin is KOTLIN_LIB but is <set-?> when the origin is KOTLIN, while it was always <set-?> in KSP1.

Repro: https://github.com/kuanyingchou/ksp/commit/49600e0fd5933bee4338eaee9b7b7dfe86636fa8

neetopia commented 6 months ago

does this impact any of your use cases? I think the name itself is not well defined in spec, therefore this is an either way works case, let me know if you have code that directly depends on the name of this setter parameter.

kuanyingchou commented 6 months ago

Ah, in XProcessing we keep the parameter name user defined and change it to "p0" if we see "<set-?>" as it's not valid in source. With this change this logic doesn't work anymore because we don't know if "value" is user-defined or not. Or is there other ways to tell?

neetopia commented 6 months ago

you can check on the origin of the KSValueParameter of the property setter, I got the following output from your repro, does this help?

SYNTHETIC
KOTLIN_LIB
ting-yuan commented 6 months ago

Per discussion offline, let's

  1. check whether there's anything in the language spec, and
  2. align the naming for source and libs.
kuanyingchou commented 6 months ago

Yes, checking the origin as well as consistent names both work for us. Thanks!