Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class HookSymbolProcessor(environment: SymbolProcessorEnvironment) : SymbolProce
val hooksMetas = resolver.getSymbolsWithAnnotation(HOOK_ANNOTATION)
.filterIsInstance<KSClassDeclaration>()
.mapNotNull { hookClass ->
var hasUnresolvedClassDependency = false
val hookMeta = hookClass.annotations.findAnnotation(HOOK_ANNOTATION) ?: run {
logger.error("@HookMeta annotation not found on element", hookClass)
return@mapNotNull null
Expand All @@ -54,17 +55,23 @@ class HookSymbolProcessor(environment: SymbolProcessorEnvironment) : SymbolProce

if (clazzValue.isError) {
deferred += hookClass
hasUnresolvedClassDependency = true
return@mapNotNull null
}

val closestClass = clazzValue.declaration.closestClassDeclaration()
if (closestClass == null) {
deferred += hookClass
Comment on lines 57 to 64
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a hook class has multiple @DependsOnClass annotations with unresolved dependencies, hookClass will be added to the deferred list multiple times (lines 57 and 64). This could lead to duplicate entries in the deferred list and potentially reprocessing the same hook multiple times in subsequent rounds.

Consider adding the hook to deferred only once, either by checking if it's already in the list before adding, or by deferring the addition until after all annotations are processed (e.g., moving it to lines 71-73 where the flag is checked).

Copilot uses AI. Check for mistakes.
hasUnresolvedClassDependency = true
return@mapNotNull null
}
closestClass.toBinaryName()
}

if (hasUnresolvedClassDependency) {
return@mapNotNull null
}

val dependsOnClassName = hookClass.annotations.findAnnotations(DEPENDS_ON_CLASS_NAME_ANNOTATION)
.mapNotNull { annotation ->
val classNameValue =
Expand Down Expand Up @@ -152,4 +159,4 @@ class HookSymbolProcessor(environment: SymbolProcessorEnvironment) : SymbolProce
it.annotationType.resolve().declaration.qualifiedName?.asString() == annotationClassName
}
}
}
}