Skip to content

Kotlin recipe DSL: preserve scan/generate phases in K2 synthesis#8269

Draft
timtebeek wants to merge 1 commit into
mainfrom
tim/osaka-v2
Draft

Kotlin recipe DSL: preserve scan/generate phases in K2 synthesis#8269
timtebeek wants to merge 1 commit into
mainfrom
tim/osaka-v2

Conversation

@timtebeek

Copy link
Copy Markdown
Member

The rewrite-kotlin K2 compiler plugin synthesized every imperative recipe(...) as a plain Recipe overriding only getVisitor(), so scan { }.generate { } and bare generate { } recipes silently emitted nothing and scan { }.edit { } ran its edit against an empty (never-scanned) accumulator. Recipes that declare a scan/generate phase are now synthesized as a field-less ScanningRecipe<Any> subclass whose four lifecycle methods delegate to new buildImperative* runtime helpers, preserving every phase while staying Jackson-roundtrippable. Detection unwraps the IMPLICIT_COERCION_TO_UNIT that K2 wraps around a scan { }.generate { } statement (whose Scan.generate returns non-Unit), which is why only that shape slipped through; edit-only recipes keep the lighter Recipe + getVisitor() path. Adds RecipePluginScanningTest covering scan+generate, scan+edit, bare generate, and the synthesized-class shape.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request kotlin

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant