Repository navigation
Preserve all originating elements for KSP incremental processing - #5370
Merged
Merged
Conversation
`XTypeSpecs.Builder.addOriginatingElement()` currently overwrites the previous element. Components with multiple generated modules therefore lose input dependencies needed by KSP incremental processing. Editing only the component can make the next build fail because an unchanged generated module is missing. The fix keeps all originating elements. Fixes #5363 This was triggered when `TypeSpec` was migrated to `XTypeSpec` in 7c4622d. Javapoet's `addOriginatingElement` correctly tracks elements as a list. https://github.com/square/javapoet/blob/b9017a9503b76e11b4ad4c1a9f050e2d29112cb0/src/main/java/com/squareup/javapoet/TypeSpec.java#L429 Validation: - The new Gradle regression fails with the unpatched compiler on its second build: `ActivityModule_Activity` could not be resolved. It passes with this patch using Kotlin 2.3.21 and KSP 2.3.7. - Both tests in `IncrementalProcessingTest` pass against the patched local snapshot. - Bazel tests pass: `XTypeSpecsTest`, `XCodeBlocksTest`, `XMethodElementsTest`, `ComponentProcessorTest`, `ComponentShardTest`, and `KspComponentProcessorTest`. - `git diff --check` passes. Fixes #5360 RELNOTES=N/A COPYBARA_INTEGRATE_REVIEW=#5360 from nolanpollack-stripe:fix-originating-elements 8b39069 PiperOrigin-RevId: 1026714370
copybara-service
Bot
force-pushed
the
test_1023204044
branch
from
November 20, 2026 21:32
d5e4aa6 to
6949f0b
Compare
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.
Preserve all originating elements for KSP incremental processing
XTypeSpecs.Builder.addOriginatingElement()currently overwrites the previous element.Components with multiple generated modules therefore lose input dependencies needed by KSP incremental processing. Editing only the component can make the next build fail because an unchanged generated module is missing.
The fix keeps all originating elements.
Fixes #5363
This was triggered when
TypeSpecwas migrated toXTypeSpecin 7c4622d. Javapoet'saddOriginatingElementcorrectly tracks elements as a list.https://github.com/square/javapoet/blob/b9017a9503b76e11b4ad4c1a9f050e2d29112cb0/src/main/java/com/squareup/javapoet/TypeSpec.java#L429
Validation:
ActivityModule_Activitycould not be resolved. It passes with this patch using Kotlin 2.3.21 and KSP 2.3.7.IncrementalProcessingTestpass against the patched local snapshot.XTypeSpecsTest,XCodeBlocksTest,XMethodElementsTest,ComponentProcessorTest,ComponentShardTest, andKspComponentProcessorTest.git diff --checkpasses.Fixes #5360
RELNOTES=N/A
FUTURE_COPYBARA_INTEGRATE_REVIEW=#5360 from nolanpollack-stripe:fix-originating-elements 8b39069