Skip to content

Commit

Permalink
Improve rule even more
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Aug 7, 2022
1 parent 9b07c17 commit 1f289af
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -18,7 +18,8 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
import org.jetbrains.kotlin.psi.KtReferenceExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.typeUtil.supertypes
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny
import kotlin.reflect.KClass

/**
Expand Down Expand Up @@ -79,8 +80,7 @@ class RequiresTypeResolution(config: Config = Config.empty) : Rule(config) {

context(BaseRule) private inline fun <reified T : Any> KtClass.extendsFrom(kClass: KClass<T>): Boolean {
return bindingContext[BindingContext.CLASS, this]
?.defaultType
?.supertypes()
?.getAllSuperclassesWithoutAny()
.orEmpty()
.any { it.fqNameOrNull()?.toString() == checkNotNull(kClass.qualifiedName) }
}
Expand Down

0 comments on commit 1f289af

Please sign in to comment.