KT-64882 Fix KAPT stub for useJvmIr=False #5242
Open
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.
KT-64882 I found KAPT useJvmIr=false have stub gen wrongness (all function is missing from stub)
After debug i found the reason functions are missing in stub!
The direct reason is, in ClassFileToSourceStubConverter.kt,
kaptContext.origins
contain methods with nulldescriptor
, causing “convertMethod” to return skip the method.As to how is the method's
origin.descriptor
get lost, i found it's lost during theorigin.unwrapOrigin()
anddeclaration.wrapToOrigin()
ofClassBuilderExtensionAdapter
. Anything that's not JvmIrDeclarationOrigin became NO_ORIGIN after a round of wrap and unwrap (But things are always not JvmIrDeclaration when useJvmIr=false). So existence of any ClassGeneratorExtension (like JvmAbiGen) will make the origin lost its descriptorI tried skipping ClassBuilderExtensionAdapter in GenerationState.loadClassBuilderInterceptors whenever isIrBackend=false, and the problem is indeed gone, which confirmed this is the cause
Synced with @udalov and confirmed this solution make sense and can submit PR