Compose statement-level View operators (e.g. Text + Text)#255
Merged
marcprux merged 1 commit intoJun 18, 2026
Merged
Conversation
A statement-level operator expression that evaluates to a View — most
notably `Text + Text` concatenation — was built but never composed: the
ViewBuilder transform only added a `.Compose(composectx)` tail call to
APICallExpression statements, so a bare `Text("a") + Text("b")` was
constructed and discarded (no Compose node, zero size). Wrapping it in
`.frame(...)` "fixed" it only because the outer call then got the tail
call.
Add a tail call for statement-level binary-operator expressions whose
inferred result type conforms to View, wrapping the operator in
parentheses so `.Compose` applies to the whole result rather than its
right-hand operand: `(Text("a") + Text("b")).Compose(composectx)`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vincentborko
added a commit
to vincentborko/skip-ui
that referenced
this pull request
Jun 2, 2026
`static func + (Text, Text)` was previously `fatalError()`, so any SwiftUI that builds a multi-style inline string by concatenation (per-segment color / weight / size / italic / monospaced / underline / strikethrough / gradient) could not run on Android. Both runtimes now feed one ordered `[TextRun]` model: - Skip Lite (transpiled) via a native `+` operator (`Text.plus`, `// SKIP DECLARE: operator fun plus`), capturing each operand's styling as `TextRunStyle` data (a styled `Text` applies its style as an environment modifier that can't be read back at render time). - SkipFuse via `init(bridgedRuns:colors:fontSizes:fontWeights:flags:)`, which folds primitive per-run descriptors into the same `[TextRun]`. The concatenation *is* a `_Text` carrying its `runs`, folded into a single `AnnotatedString` (each run's styling as a `SpanStyle`) and rendered by the shared `_Text.Render` path — so environment concerns (alignment, line limit + truncation, tracking, line spacing, `material3Text`) behave like any other `Text`, with no duplicated render logic. Pairs with skiptools/skip-fuse-ui#118 (the SkipSwiftUI run model). Bare, unconstrained `Text + Text` requires the transpiler fix in skiptools/skipstone#255 to be composed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 2, 2026
Member
|
Looks good, thanks! |
1 task
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.
What
A statement-level operator expression that evaluates to a
View— most notablyText + Textconcatenation — was built into the view tree but never composed.translateViewBuilderonly appended a.Compose(composectx)tail call toAPICallExpressionstatements. A bareText("a") + Text("b")is an infix-operator (SequenceExpr) statement, so neither the operator nor its operands (whose parent is the operator, not the statement) ever got the tail call. The concatenationTextwas constructed and discarded — no Compose node, zero size. Wrapping it in.frame(...)"fixed" it only because the outer.frame(...)call is anAPICallExpressionthat gets composed.How
KotlinBinaryOperatornow carries itsinferredType(set intranslatefrom the Swift expression's inferred type).translateViewBuilderadds a tail call for statement-levelKotlinBinaryOperators whose resultisSwiftUIType("View", ...)(and which aren't an assignment), wrapping the operator inKotlinParenthesizedso.Composeapplies to the whole result rather than binding to the right-hand operand:The View-type gate means non-View operators (
Int + Int,String + String, …) are unaffected.Testing
swift test— addedSwiftUITests.testViewProducingOperatorTailCall; fullSkipSyntaxTestssuite green (834 tests, 0 failures).Text + Text(per-run color, weight, italic, monospaced, mixed sizes, decorations, gradient, multi-line wrapping) all render.Why this is the right layer
This is the Skip Lite (transpiled) fix. It unblocks the bare/unconstrained
Text + Textpath used by:+operator +AnnotatedStringrenderer.skiptools/skip-fuse-ui#118 is the SkipFuse counterpart of the same feature; SkipFuse compiles Swift natively (no
translateViewBuilderpass) and is not affected by this change. The missing tail call was the sole reason a bare concatenation collapsed to zero size in transpiled apps..Compose), the fix and test were authored against the existingtranslateViewBuilderlogic, and verified with the fullSkipSyntaxTestssuite plus on-device rendering.🤖 Generated with Claude Code