fix!: align APT and KSP metamodel generation and make the Java processor incremental-safe - #439
Merged
Merged
Conversation
…sor incremental-safe The Java processor generates the <Type>NullableMetamodel chain variant and selects child metamodel fields by derived nullability, so a field reads as the same static type from Java and Kotlin. KSP sources components from the primary constructor (a body-declared or inherited property has no column), filters sealed interface properties to abstract ones, and escapes keyword-named properties at every emission site. The Java processors register with Gradle as aggregating incremental annotation processors, and a generation failure reports the failing record with its stack trace and aborts instead of continuing without a source location.
…g and keyword escaping in the Data paths The Owner_ interface types a nullable foreign key as the nullable-chain child metamodel, sealed Data interfaces get both chain variants, the unique-key nullability warning prints once per record, and KSP escapes keyword-named properties in the metamodel interface and the primary-key isSame comparison. The KSP suite also locks child selection by property nullability, mirroring the Java assertions.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Aligns the Java (APT) and Kotlin (KSP) metamodel processors on one contract and makes the Java processor safe for Gradle incremental annotation processing.
Java processor quality
META-INF/gradle/incremental.annotation.processorsregistersMetamodelProcessorandTypeIndexProcessorasaggregating, so attaching them no longer disables incremental compilation for the whole source set. Isolating is not an option: the instantiator services file and the type index aggregate cross-record state. The processors keep@SupportedAnnotationTypes("*")and root-element iteration deliberately — discovery is interface-based, and a record may implementData/Projectionwith no annotations at all, so claiming specific annotation types would make javac skip the processor for such files in every build system. KSP discovers the same way throughgetAllFiles().IOException, so a codegen defect propagates with a source location instead of printing a bareError: java.lang.NullPointerExceptionand continuing.APT/KSP divergence
<Type>NullableMetamodelchain variant for every record and sealed interface and selects child metamodel fields by derived nullability (explicit annotations, null-marked default), soOwner_.addresshas the same static type in Java and Kotlin.instance()stays on the base Data variant, validation diagnostics print once per record (gated to the base pass, in both processors), and the GraalVM feature already registers both class names, so native images need no change.val display: String get() = ...) or an inherited one has no column and no longer receives a metamodel field pointing at a nonexistent column. Sealed interfaces contribute abstract properties only, matching APT's abstract-getter filter, andhasNullableLeafwalks the same component set.`object`,`fun`, …) at every identifier emission site; path and field string literals keep the raw name, so column derivation is unchanged. Java needs no counterpart: javac rejects keyword-named record components at declaration.Verification
MetamodelProcessorTestsuites: nullable child selection, nullable-variant emission and descriptor registration (Java); constructor-only components and keyword-named property compilation (KSP).clean installgreen on JDK 21.Fixes #411