You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
isPlatformCode() is then used to find out if a generated function needs the actual keyword.
I believe/hope there must be a more elegant solution for isPlatformCode().
Any ideas are welcome.
Or even better: Could isPlatformCode() be part of KSP API?
That would be very convenient for implementing expect/actual solutions.
The text was updated successfully, but these errors were encountered:
I'm generating code with KSP. The generated code will be used in common/intermediate code.
I understand that this is not allowed.
See https://slack-chats.kotlinlang.org/t/16366233/i-m-trying-out-kotlin-2-0-beta-3-and-it-looks-like-generated:
Common/intermediate (= none-platform) code cannot reference generated code in the compilation of platform code.
Generated codes are treated as platform code (you'll have to use expect/actual).
I therefore implemented the proposed expect/actual solution.
Everything works fine (see https://github.com/softappeal/yass2/blob/main/yass2-generate/src/jvmMain/kotlin/ksp/Generate.kt).
For finding out if a
KSDeclaration
is in platform specific code I use the following code:isPlatformCode()
is then used to find out if a generated function needs theactual
keyword.I believe/hope there must be a more elegant solution for
isPlatformCode()
.Any ideas are welcome.
Or even better: Could
isPlatformCode()
be part of KSP API?That would be very convenient for implementing
expect/actual
solutions.The text was updated successfully, but these errors were encountered: