You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a SubclassRelationCache that stores the result of KClass.isSubclassOf lookups, expose a KClass<*>.isSubclassOfCached(base: KClass<*>) helper, and route every current kClass.isSubclassOf call site through it. Once no direct usages remain, forbid importing kotlin.reflect.full.isSubclassOf with detekt so future code must use the cached helper.
Scope and constraints
Cache the boolean result of isSubclassOf keyed by the subclass/superclass KClass pair.
Provide the helper fun KClass<*>.isSubclassOfCached(base: KClass<*>).
Preserve existing isSubclassOf semantics exactly, including self-relation and interface checks.
Replace every current kClass.isSubclassOf usage: ListResolver, SetResolver, MapResolver, OptionalResolver, and ClassResolver.
Add kotlin.reflect.full.isSubclassOf as a prohibited import in the shared detekt configuration.
Ensure correctness when resolver instances are shared across threads.
Leave existing isSubtypeOf checks (List/Set/Map mutability) out of scope.
Description
Create a
SubclassRelationCachethat stores the result ofKClass.isSubclassOflookups, expose aKClass<*>.isSubclassOfCached(base: KClass<*>)helper, and route every currentkClass.isSubclassOfcall site through it. Once no direct usages remain, forbid importingkotlin.reflect.full.isSubclassOfwith detekt so future code must use the cached helper.Scope and constraints
isSubclassOfkeyed by the subclass/superclassKClasspair.fun KClass<*>.isSubclassOfCached(base: KClass<*>).isSubclassOfsemantics exactly, including self-relation and interface checks.kClass.isSubclassOfusage:ListResolver,SetResolver,MapResolver,OptionalResolver, andClassResolver.kotlin.reflect.full.isSubclassOfas a prohibited import in the shared detekt configuration.isSubtypeOfchecks (List/Set/Map mutability) out of scope.References
core/src/main/kotlin/dev/appoutlet/some/resolver/ListResolver.ktcore/src/main/kotlin/dev/appoutlet/some/resolver/SetResolver.ktcore/src/main/kotlin/dev/appoutlet/some/resolver/MapResolver.ktcore/src/main/kotlin/dev/appoutlet/some/resolver/OptionalResolver.ktcore/src/main/kotlin/dev/appoutlet/some/resolver/ClassResolver.ktScope
Add
SubclassRelationCacheandisSubclassOfCached, migrate all currentisSubclassOfusages, enable the prohibited-import rule, and add tests.Out of scope: changing subclass rules, resolver ordering, caching
isSubtypeOf, or the publicResolverAPI.Acceptance criteria
SubclassRelationCacheexposes a lookup that returns the same result asKClass.isSubclassOf.KClass<*>.isSubclassOfCached(base: KClass<*>)is available and delegates to the cache.isSubclassOfusage inListResolver,SetResolver,MapResolver,OptionalResolver, andClassResolvergoes throughisSubclassOfCached.kotlin.reflect.full.isSubclassOfis flagged by detekt and./gradlew detektfails when it is used.canResolvebehavior is unchanged, including rejection ofString,Number,Boolean,Char, andList/Set/Mapsubclasses inClassResolver.