Fix flaky KSP error for @DeepLink methods in Kotlin objects#393
Merged
Conversation
XProcessing's isStatic() for KSP relies on annotation type resolution to detect @JvmStatic. This can intermittently fail during incremental compilation with KSP2's Analysis API, causing methods in Kotlin object declarations to appear non-static. Add a fallback check in verifyMethod() that also accepts methods whose enclosing type is a Kotlin object, since all methods in objects are effectively static in JVM bytecode regardless of @JvmStatic.
bwang95
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isStatic()for KSP relies on annotation type resolution to detect@JvmStatic. This can intermittently fail during incremental compilation with KSP2's Analysis API, causing methods in Kotlinobjectdeclarations to appear non-static and triggeringOnly static methods can be annotated with @DeepLink.verifyMethod()that also accepts methods whose enclosing type is a Kotlinobject, since all methods in objects are effectively static in JVM bytecode.object FooDeepLinkswith@JvmStaticmethods) is used in 25+ modules in the Airbnb Android app.Root Cause
The
isStatic()check in XProcessing (KSDeclarationExt.kt) has 4 fallback checks for KSP:JAVA_STATICmodifier — never set for Kotlin source (by design, KSP#378)hasJvmStaticAnnotation()— resolves annotation type viaannotationType.resolve().declaration.qualifiedName— can fail if resolution returns an error typeisCompanionObject— false for plainobject(only true forcompanion object)objectIS the enclosing class)For methods in a plain
object, check 2 is the only one that can succeed. When KSP2's lazy FIR-based annotation resolution intermittently fails during incremental builds, all 4 checks fail and the processor throws.Test Plan
testMethodInKotlinObjectWithJvmStaticCompilestestNonStaticMethodInClassStillFails