Skip to content

Commit

Permalink
Disable werror due to warning of cucurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Jan 15, 2025
1 parent b936f0b commit 406910d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
7 changes: 6 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
var sharedSwiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("BareSlashRegexLiterals"),
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("InferSendableFromCaptures"),
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
.swiftLanguageMode(.v5),
]
Expand Down Expand Up @@ -74,7 +75,11 @@ if development {

let warningsAsErrorsCondition = envEnable("OPENSWIFTUI_WERROR", default: isXcodeEnv && development)
if warningsAsErrorsCondition {
sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"]))
// Hold off the werror feature as we can't avoid the concurrency warning.
// Reenable the folllowing after swift-evolution#443 is release.

// sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"]))
// sharedSwiftSettings.append(.unsafeFlags(["-Wwarning", "concurrency"]))
}

// NOTE:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
// Status: WIP

@frozen
public struct _EnvironmentKeyWritingModifier<Value>: ViewModifier/*, _GraphInputsModifier*/ {
public struct _EnvironmentKeyWritingModifier<Value>: ViewModifier, _GraphInputsModifier, PrimitiveViewModifier {
public var keyPath: WritableKeyPath<EnvironmentValues, Value>
public var value: Value

@inlinable
@inline(__always)
public init(keyPath: WritableKeyPath<EnvironmentValues, Value>, value: Value) {
self.keyPath = keyPath
self.value = value
Expand All @@ -20,11 +19,15 @@ public struct _EnvironmentKeyWritingModifier<Value>: ViewModifier/*, _GraphInput
public static func _makeInputs(modifier: _GraphValue<_EnvironmentKeyWritingModifier<Value>>, inputs: inout _GraphInputs) {
// TODO
}


}

@available(*, unavailable)
extension _EnvironmentKeyWritingModifier: Sendable {}

extension View {
@inlinable
@inline(__always)
nonisolated public func environment<V>(_ keyPath: WritableKeyPath<EnvironmentValues, V>, _ value: V) -> some View {
modifier(_EnvironmentKeyWritingModifier<V>(keyPath: keyPath, value: value))
}
Expand Down
72 changes: 37 additions & 35 deletions Sources/OpenSwiftUICore/Modifier/ViewModifier/ViewModifier.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ViewModifier.swift
// OpenSwiftUI
// OpenSwiftUICore
//
// Audited for iOS 15.5
// Status: Complete
Expand Down Expand Up @@ -48,68 +48,45 @@
/// Downtown Bus. A view extension, using custom a modifier, renders the
/// caption in blue text surrounded by a rounded
/// rectangle.](OpenSwiftUI-View-ViewModifier.png)
@MainActor
@preconcurrency
public protocol ViewModifier {
/// The type of view representing the body.
associatedtype Body: View

/// Makes a new view using the view modifier and inputs that you provide.
static func _makeView(
nonisolated static func _makeView(
modifier: _GraphValue<Self>,
inputs: _ViewInputs,
body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs
) -> _ViewOutputs

static func _makeViewList(
nonisolated static func _makeViewList(
modifier: _GraphValue<Self>,
inputs: _ViewListInputs,
body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs
) -> _ViewListOutputs

/// The number of views that `_makeViewList()` would produce, or
/// nil if unknown.
static func _viewListCount(
nonisolated static func _viewListCount(
inputs: _ViewListCountInputs,
body: (_ViewListCountInputs) -> Int?
) -> Int?

/// The content view type passed to `body()`.
typealias Content = _ViewModifier_Content<Self>
/// The type of view representing the body.
associatedtype Body: View

/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
@ViewBuilder
@MainActor
@preconcurrency
func body(content: Content) -> Body
}

extension ViewModifier {
public static func _makeView(
modifier: _GraphValue<Self>,
inputs: _ViewInputs,
body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs
) -> _ViewOutputs {
makeView(modifier: modifier, inputs: inputs, body: body)
}

public static func _makeViewList(
modifier: _GraphValue<Self>,
inputs: _ViewListInputs,
body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs
) -> _ViewListOutputs {
makeViewList(modifier: modifier, inputs: inputs, body: body)
}

public static func _viewListCount(
inputs: _ViewListCountInputs,
body: (_ViewListCountInputs) -> Int?
) -> Int? {
viewListCount(inputs: inputs, body: body)
}
/// The content view type passed to `body()`.
typealias Content = _ViewModifier_Content<Self>
}

package protocol PrimitiveViewModifier: ViewModifier where Body == Never {}

extension ViewModifier where Body == Never {
public func body(content _: Content) -> Never {
bodyError()
Expand Down Expand Up @@ -163,3 +140,28 @@ extension ViewModifier {
preconditionFailure("body() should not be called on \(Self.self)")
}
}

extension ViewModifier {
public static func _makeView(
modifier: _GraphValue<Self>,
inputs: _ViewInputs,
body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs
) -> _ViewOutputs {
makeView(modifier: modifier, inputs: inputs, body: body)
}

public static func _makeViewList(
modifier: _GraphValue<Self>,
inputs: _ViewListInputs,
body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs
) -> _ViewListOutputs {
makeViewList(modifier: modifier, inputs: inputs, body: body)
}

public static func _viewListCount(
inputs: _ViewListCountInputs,
body: (_ViewListCountInputs) -> Int?
) -> Int? {
viewListCount(inputs: inputs, body: body)
}
}

0 comments on commit 406910d

Please sign in to comment.