-
Notifications
You must be signed in to change notification settings - Fork 335
Description
KSName isn't ideal for handling non-trivial class names, such as heavily nested types. KotlinPoet's ClassName.bestGuess()
API is used in the Glide example project, but that API should really only be used as a last resort.
In Kotlin's internals and metadata, it has a pattern for its names that is deterministic (e.g. "org/foo/bar/Baz.Nested"
). It would be ideal if this name was exposed or otherwise surfaced a more concrete API.
Here's an implementation we have in KotlinPoet for piecing together a name from it: https://github.com/square/kotlinpoet/blob/06aad8e024aaa453477d420ad65cfe4af9e84f3a/kotlinpoet-metadata-specs/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/internal/ClassInspectorUtil.kt#L171-L209
Example of where KSName currently falls short:
- Given this name:
dev.zacsweers.moshisealed.sample.test.MessageTest.MessageWithNullDefault
- The result of
getQualifier
isdev.zacsweers.moshisealed.sample.test.MessageTest
🤔