Skip to content

[CodePrinting] add printGuardBlock#798

Merged
ktoso merged 2 commits into
swiftlang:mainfrom
ktoso:add-codeprinter-printguard
Jun 20, 2026
Merged

[CodePrinting] add printGuardBlock#798
ktoso merged 2 commits into
swiftlang:mainfrom
ktoso:add-codeprinter-printguard

Conversation

@ktoso

@ktoso ktoso commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Mirror printIfBlock for Swift guard <cond> else { … } blocks, so generators don't have to spell printBraceBlock("guard \(cond) else") inline.

ktoso and others added 2 commits June 20, 2026 14:37
Mirror `printIfBlock` for Swift `guard <cond> else { … }` blocks, so
generators don't have to spell `printBraceBlock("guard \(cond) else")`
inline. Migrates the one existing call site in
`JNISwift2JavaGenerator+SwiftThunkPrinting.swift` to use it.

The condition is passed through verbatim — `guard` in Swift is written
without parentheses around the condition, and the condition often binds
(`let x = optional`) so wrapping it would be wrong.
@ktoso ktoso merged commit 913ff7e into swiftlang:main Jun 20, 2026
41 of 42 checks passed
@ktoso ktoso deleted the add-codeprinter-printguard branch June 20, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant