Skip to content

Fix mismatched optional/static view aliases#924

Open
jcmosc wants to merge 1 commit into
OpenSwiftUIProject:mainfrom
jcmosc:fix-optional-view-alias
Open

Fix mismatched optional/static view aliases#924
jcmosc wants to merge 1 commit into
OpenSwiftUIProject:mainfrom
jcmosc:fix-optional-view-alias

Conversation

@jcmosc

@jcmosc jcmosc commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

For static view aliases, i.e. where AnySource.valueIsNil is itself nil (i.e. not nillable), the view type is just Source.
For optional view aliases, i.e. where AnySource.valueIsNil can be evaluated, the view type is Optional<Source>.

@jcmosc jcmosc requested a review from Kyle-Ye as a code owner July 1, 2026 15:01
@augmentcode

augmentcode Bot commented Jul 1, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Fixes how view aliases choose their debuggable view type based on whether the underlying source is nillable.

Changes:

  • Uses Source for static aliases (valueIsNil == nil) and Optional<Source> for optional aliases across view, view-list, and view-list-count paths.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

)
} else {
Source.makeDebuggableView(
Optional<Source>.makeDebuggableView(

@augmentcode augmentcode Bot Jul 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sources/OpenSwiftUI/View/Configuration/ViewAlias.swift:233: In the source.valueIsNil != nil branch, using Optional<Source> here can become a double-optional (V??) since AnySource.init(Attribute<V?>) sets formula = SourceFormula<V?>, which may cause a mismatched Attribute(identifier:) cast at runtime. Can you confirm the intended Source generic in this branch is the non-optional wrapped view type (not already Optional<Wrapped>)?

Severity: medium

Other Locations
  • Sources/OpenSwiftUI/View/Configuration/ViewAlias.swift:254
  • Sources/OpenSwiftUI/View/Configuration/ViewAlias.swift:268

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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