Kotlin recipe DSL: preserve scan/generate phases in K2 synthesis#8269
Draft
timtebeek wants to merge 1 commit into
Draft
Kotlin recipe DSL: preserve scan/generate phases in K2 synthesis#8269timtebeek wants to merge 1 commit into
timtebeek wants to merge 1 commit into
Conversation
Imperative recipe(...) calls were synthesized as a plain Recipe overriding
only getVisitor(), so scan { }.generate { } and bare generate { } emitted
nothing and scan { }.edit { } ran against an empty accumulator. Recipes that
declare a scan/generate phase are now synthesized as a field-less
ScanningRecipe subclass whose lifecycle methods delegate to new buildImperative*
runtime helpers, preserving every phase.
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.
The rewrite-kotlin K2 compiler plugin synthesized every imperative
recipe(...)as a plainRecipeoverriding onlygetVisitor(), soscan { }.generate { }and baregenerate { }recipes silently emitted nothing andscan { }.edit { }ran its edit against an empty (never-scanned) accumulator. Recipes that declare a scan/generate phase are now synthesized as a field-lessScanningRecipe<Any>subclass whose four lifecycle methods delegate to newbuildImperative*runtime helpers, preserving every phase while staying Jackson-roundtrippable. Detection unwraps theIMPLICIT_COERCION_TO_UNITthat K2 wraps around ascan { }.generate { }statement (whoseScan.generatereturns non-Unit), which is why only that shape slipped through; edit-only recipes keep the lighterRecipe+getVisitor()path. AddsRecipePluginScanningTestcovering scan+generate, scan+edit, bare generate, and the synthesized-class shape.