From 243b9bdcbbdb99a9474eaa8b88dac221c432f8e7 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 20 Nov 2024 00:25:06 -0500 Subject: [PATCH] KSP2 returns synthetic constructors for objects --- .../me/tatarka/inject/compiler/TypeResultResolver.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt index f5fb325f..d9a9e80a 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt @@ -242,15 +242,16 @@ class TypeResultResolver(private val provider: AstProvider, private val options: } val astClass = key.type.toAstClass() + + if (astClass.isObject && astClass.isInject()) { + return Object(astClass.type) + } + val injectCtor = astClass.findInjectConstructors(provider.messenger, options) if (injectCtor != null) { return constructor(key, injectCtor, astClass) } - if (astClass.isInject() && astClass.isObject) { - return Object(astClass.type) - } - if (astClass.isAssistedFactory()) { return assistedFactory(astClass, key) }