diff options
author | Martin Bonnin <martin@mbonnin.net> | 2021-08-12 16:17:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 10:17:00 -0400 |
commit | cf395c1b384d2599516dc61fa68daa1209ed7e88 (patch) | |
tree | 67bfb936cbdd70d6811133573aa8e67dc901fce5 /kotlinpoet | |
parent | a03fcd79bbc1f29a7548f905d1546238ec8ddd40 (diff) | |
download | kotlinpoet-cf395c1b384d2599516dc61fa68daa1209ed7e88.tar.gz |
Add a doc about kotlin-reflect (#1116)
* update doc to mention kotlin-reflect
* Update docs/index.md
Co-authored-by: Egor Andreevich <github@egorand.dev>
* Update docs/index.md
Co-authored-by: Egor Andreevich <github@egorand.dev>
* Update kotlinpoet/src/main/java/com/squareup/kotlinpoet/TypeName.kt
Co-authored-by: Egor Andreevich <github@egorand.dev>
* Update kotlinpoet/src/main/java/com/squareup/kotlinpoet/ParameterizedTypeName.kt
Co-authored-by: Egor Andreevich <github@egorand.dev>
* Update index.md
Co-authored-by: Egor Andreevich <github@egorand.dev>
Diffstat (limited to 'kotlinpoet')
-rw-r--r-- | kotlinpoet/src/main/java/com/squareup/kotlinpoet/ParameterizedTypeName.kt | 5 | ||||
-rw-r--r-- | kotlinpoet/src/main/java/com/squareup/kotlinpoet/TypeName.kt | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/kotlinpoet/src/main/java/com/squareup/kotlinpoet/ParameterizedTypeName.kt b/kotlinpoet/src/main/java/com/squareup/kotlinpoet/ParameterizedTypeName.kt index d5733909..e65b7883 100644 --- a/kotlinpoet/src/main/java/com/squareup/kotlinpoet/ParameterizedTypeName.kt +++ b/kotlinpoet/src/main/java/com/squareup/kotlinpoet/ParameterizedTypeName.kt @@ -202,7 +202,10 @@ public class ParameterizedTypeName internal constructor( public fun ParameterizedType.asParameterizedTypeName(): ParameterizedTypeName = ParameterizedTypeName.get(this, mutableMapOf()) -/** Returns a class name equivalent to given Kotlin KType. */ +/** + * Returns a [TypeName] equivalent to the given Kotlin KType using reflection, maybe using kotlin-reflect + * if required. + */ public fun KType.asTypeName(): TypeName { val classifier = this.classifier if (classifier is KTypeParameter) { diff --git a/kotlinpoet/src/main/java/com/squareup/kotlinpoet/TypeName.kt b/kotlinpoet/src/main/java/com/squareup/kotlinpoet/TypeName.kt index 6cd1b78a..58f885c0 100644 --- a/kotlinpoet/src/main/java/com/squareup/kotlinpoet/TypeName.kt +++ b/kotlinpoet/src/main/java/com/squareup/kotlinpoet/TypeName.kt @@ -290,5 +290,9 @@ public fun KClass<*>.asTypeName(): ClassName = asClassName() @JvmName("get") public fun Type.asTypeName(): TypeName = TypeName.get(this, mutableMapOf()) +/** + * Returns a [TypeName] equivalent of the reified type parameter [T] using reflection, maybe using kotlin-reflect + * if required. + */ @ExperimentalStdlibApi public inline fun <reified T> typeNameOf(): TypeName = typeOf<T>().asTypeName() |