Summary
Given a build with KSP 2.3.6 and an Android Application or Library with AGP9 & built-in Kotlin, KSP processors using validate will not able to process symbols that involve the generated R file unless the explicit type is declared
I've attached a project with a sample processor MyAnnotationProcessor for @MyAnnotation that records the symbols processed & the symbols that were deferred after all rounds. I then declared the following in the Android :app module, where R.string.sample_label is an existing Android String resource:
@MyAnnotation
class SampleAnnotatedClass(
val name: String,
) {
val labelRes = R.string.sample_label
}
With builtin Kotlin, MyAnnotationProcessor will defer SampleAnnotatedClass every round because it cannot resolve the type of labelRes. However, if you compile the project without builtin Kotlin & apply kotlin-android instead, it immediately is able to process SampleAnnotatedClass
ksp-agp9-bug.zip
$ ./gradlew :app:kspDebugKotlin --warn --rerun-tasks
w: [ksp] MyAnnotation processor finish deferred symbols: SampleAnnotatedClass
$ ./gradlew :app:kspDebugKotlin --warn --rerun-tasks -Pandroid.builtInKotlin=false -Pandroid.newDsl=false
w: [ksp] MyAnnotation processor saw class: dev.jonamireh.ksp_agp9.SampleAnnotatedClass with declarations: name, labelRes, <init>
w: [ksp] MyAnnotation processor finish deferred symbols: <empty>
Related: #2748
Summary
Given a build with KSP 2.3.6 and an Android Application or Library with AGP9 & built-in Kotlin, KSP processors using
validatewill not able to process symbols that involve the generated R file unless the explicit type is declaredI've attached a project with a sample processor
MyAnnotationProcessorfor@MyAnnotationthat records the symbols processed & the symbols that were deferred after all rounds. I then declared the following in the Android:appmodule, whereR.string.sample_labelis an existing Android String resource:With builtin Kotlin,
MyAnnotationProcessorwill deferSampleAnnotatedClassevery round because it cannot resolve the type oflabelRes. However, if you compile the project without builtin Kotlin & applykotlin-androidinstead, it immediately is able to processSampleAnnotatedClassksp-agp9-bug.zip
Related: #2748