Skip to content

Commit

Permalink
Defer optics generation of invalid classes to later ksp rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmave126 committed Nov 19, 2024
1 parent b490817 commit 35b97f5
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ class OpticsProcessor(
) :
SymbolProcessor {
override fun process(resolver: Resolver): List<KSAnnotated> {
resolver
val (resolved, deferred) = resolver
.getSymbolsWithAnnotation("arrow.optics.optics")
.filterIsInstance<KSClassDeclaration>()
.forEach(::processClass)
.partition { it.validate() }
resolved.forEach(::processClass)

// the docs say that [process] should return
// "deferred symbols that the processor can't process"
// and in theory we have none
return emptyList()
// If types used by the annotated class are by other processors,
// such class will fail the validation. In that case, we need to
// defer the code generation for the class to the next round
return deferred
}

private fun processClass(klass: KSClassDeclaration) {
Expand Down

0 comments on commit 35b97f5

Please sign in to comment.