Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Example/Modules/Platform/cocoa/SwiftUI_SPI.swiftinterface
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ public class CAHostingLayer<Content> : QuartzCore.CALayer where Content : SwiftU
}
}

public struct DisplayList : Swift.CustomStringConvertible {
public struct Version {}
public var description: Swift.String {
get
}
}

public final class ViewGraph {
public struct Outputs : Swift.OptionSet {
public let rawValue: Swift.UInt8
public init(rawValue: Swift.UInt8)
public static var displayList: ViewGraph.Outputs {
get
}
}
public init<Root>(rootViewType: Root.Type, requestedOutputs: ViewGraph.Outputs) where Root : SwiftUI.View
public func instantiateOutputs()
public func setRootView<Root>(_ view: Root) where Root : SwiftUI.View
public func setProposedSize(_ size: CoreGraphics.CGSize)
public func displayList() -> (DisplayList, DisplayList.Version)
}

@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, visionOS 1.0, *)
extension SwiftUI.View {
public func variableBlur(maxRadius: CoreGraphics.CGFloat, mask: SwiftUI.Image, opaque: Swift.Bool = false) -> some SwiftUI.View
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,9 @@ let openSwiftUITestsSupportTarget = Target.target(
dependencies: (compatibilityTestCondition ? [] : ["OpenSwiftUI"]),
cSettings: sharedCSettings,
cxxSettings: sharedCxxSettings,
swiftSettings: sharedSwiftSettings
swiftSettings: sharedSwiftSettings + (compatibilityTestCondition ? [
.unsafeFlags(["-I", "\(Context.packageDirectory)/Example/Modules/Platform/cocoa"]),
] : [])
)

let openSwiftUIExtensionTarget = Target.target(
Expand Down Expand Up @@ -688,7 +690,9 @@ let openSwiftUICompatibilityTestTarget = Target.testTarget(
exclude: ["README.md"],
cSettings: sharedCSettings,
cxxSettings: sharedCxxSettings,
swiftSettings: sharedSwiftSettings
swiftSettings: sharedSwiftSettings + (compatibilityTestCondition ? [
.unsafeFlags(["-I", "\(Context.packageDirectory)/Example/Modules/Platform/cocoa"]),
] : [])
)

// MARK: - OpenSwiftUIBridge Target
Expand Down
16 changes: 7 additions & 9 deletions Sources/OpenSwiftUI/View/Configuration/ViewAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ViewAlias.swift
// OpenSwiftUI
//
// Audited for 6.0.87
// Audited for 6.5.4
// Status: Complete
// ID: D9F7AF928092578A4B8FA861B49E2161 (SwiftUI)

Expand All @@ -25,8 +25,6 @@ protocol ViewAlias: PrimitiveView {
init()
}

// Audited for 6.5.4

extension ViewAlias {
nonisolated public static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
var inputs = inputs
Expand Down Expand Up @@ -225,12 +223,12 @@ private struct SourceFormula<Source>: AnySourceFormula where Source: View {
return .init()
}
return if source.valueIsNil == nil {
Optional<Source>.makeDebuggableView(
Source.makeDebuggableView(
view: _GraphValue(Attribute(identifier: attribute)),
inputs: inputs
)
} 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.

view: _GraphValue(Attribute(identifier: attribute)),
inputs: inputs
)
Expand All @@ -246,12 +244,12 @@ private struct SourceFormula<Source>: AnySourceFormula where Source: View {
return .emptyViewList(inputs: inputs)
}
return if source.valueIsNil == nil {
Optional<Source>.makeDebuggableViewList(
Source.makeDebuggableViewList(
view: _GraphValue(Attribute(identifier: attribute)),
inputs: inputs
)
} else {
Source.makeDebuggableViewList(
Optional<Source>.makeDebuggableViewList(
view: _GraphValue(Attribute(identifier: attribute)),
inputs: inputs
)
Expand All @@ -263,9 +261,9 @@ private struct SourceFormula<Source>: AnySourceFormula where Source: View {
inputs: _ViewListCountInputs
) -> Int? {
if source.valueIsNil == nil {
Optional<Source>._viewListCount(inputs: inputs)
} else {
Source._viewListCount(inputs: inputs)
} else {
Optional<Source>._viewListCount(inputs: inputs)
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions Sources/OpenSwiftUITestsSupport/Render/DisplayListUtil.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// DisplayListUtil.swift
// OpenSwiftUITestsSupport

import Foundation
#if OPENSWIFTUI
package import OpenSwiftUICore
#else
package import SwiftUI_SPI
#endif

package enum DisplayListUtil {
package static func renderDisplayList<Content: View>(_ content: Content) -> String {
let graph = ViewGraph(
rootViewType: Content.self,
requestedOutputs: [.displayList]
)
graph.instantiateOutputs()
graph.setRootView(content)
graph.setProposedSize(CGSize(width: 100, height: 100))
let (displayList, _) = graph.displayList()
return displayList.description
}

package static func containsAnyColor(_ displayList: String) -> Bool {
displayList.contains("(color #")
}

package static func containsColor(_ color: String, in displayList: String) -> Bool {
displayList.contains("(color \(color))")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// DisplayListUtilCompatibilityTests.swift
// OpenSwiftUICompatibilityTests

import OpenSwiftUITestsSupport
import Testing

@MainActor
struct DisplayListUtilCompatibilityTests {
@Test
func rendersColor() {
let displayList = DisplayListUtil.renderDisplayList(Color.red)
#expect(DisplayListUtil.containsAnyColor(displayList))
}
}
Loading
Loading