From fa45e7b69641b05e90bbf4aecd69510ced7181fd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 11 Jul 2025 16:39:08 +0600 Subject: [PATCH] fix of kspCommonMainKotlinMetadata call --- koin/generator/src/main/kotlin/Processor.kt | 2 +- ksp/generator/src/main/kotlin/KClassTypeName.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/koin/generator/src/main/kotlin/Processor.kt b/koin/generator/src/main/kotlin/Processor.kt index 96e21830d88..6933cafb563 100644 --- a/koin/generator/src/main/kotlin/Processor.kt +++ b/koin/generator/src/main/kotlin/Processor.kt @@ -238,7 +238,7 @@ class Processor( """.trimIndent() ) ksFile.getAnnotationsByType(GenerateKoinDefinition::class).forEach { - val type = it.type.safeClassName() + val type = safeClassName { it.type } val targetType = runCatching { type.parameterizedBy(*(it.typeArgs.takeIf { it.isNotEmpty() } ?.map { it.asTypeName() } ?.toTypedArray() ?: return@runCatching type)) }.getOrElse { e -> diff --git a/ksp/generator/src/main/kotlin/KClassTypeName.kt b/ksp/generator/src/main/kotlin/KClassTypeName.kt index fb9f5f0fb22..dc35b0e53a7 100644 --- a/ksp/generator/src/main/kotlin/KClassTypeName.kt +++ b/ksp/generator/src/main/kotlin/KClassTypeName.kt @@ -6,9 +6,10 @@ import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.asTypeName import kotlin.reflect.KClass +@Suppress("NOTHING_TO_INLINE") @OptIn(KspExperimental::class) -fun KClass<*>.safeClassName() = runCatching { - asTypeName() +inline fun safeClassName(classnameGetter: () -> KClass<*>) = runCatching { + classnameGetter().asTypeName() }.getOrElse { e -> if (e is KSTypeNotPresentException) { ClassName(