Skip to content

Commit

Permalink
Fix some Swift 6 warnings (#224)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
  • Loading branch information
stephencelis committed Jun 12, 2024
1 parent 13de2b8 commit 00bc30c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ concurrency:
jobs:
macos:
name: macOS
runs-on: macos-13
runs-on: macos-14
strategy:
matrix:
config: ['debug', 'release']
xcode: ['14.3.1', '15.0.1']
xcode: ['14.3.1', '15.4.0']
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
Expand All @@ -45,12 +45,19 @@ jobs:
# run: make test-integration

ubuntu:
name: Linux
strategy:
matrix:
swift:
- '5.10'
name: Ubuntu (Swift ${{ matrix.swift }})
runs-on: ubuntu-latest
container: swift:${{ matrix.swift }}
steps:
- uses: actions/checkout@v4
- name: Run tests
run: make test-swift
run: swift test --parallel
- name: Run tests (release)
run: swift test -c release --parallel

# wasm:
# name: Wasm
Expand All @@ -75,17 +82,3 @@ jobs:
# run: swift test
# - name: Run tests (release)
# run: swift test -c release

static-stdlib:
strategy:
matrix:
image: ['swift:5.7-focal', 'swift:5.8-focal']
runs-on: ubuntu-latest
container:
image: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- name: Build for static-stdlib (debug)
run: swift build -c debug --static-swift-stdlib
- name: Build for static-stdlib (release)
run: swift build -c release --static-swift-stdlib
4 changes: 2 additions & 2 deletions Sources/Dependencies/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ extension ActorIsolated {
deprecated,
message: "Use the non-async version of 'withValue'."
)
public func withValue<T>(
public func withValue<T: Sendable>(
_ operation: @Sendable (inout Value) async throws -> T
) async rethrows -> T {
) async rethrows -> T where Value: Sendable {
var value = self.value
defer { self.value = value }
return try await operation(&value)
Expand Down
17 changes: 13 additions & 4 deletions Sources/Dependencies/Internal/RuntimeWarnings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func runtimeWarn(
#endif
}

#if DEBUG
// NB: We can change this to `#if DEBUG` when we drop support for Swift <5.9
#if RELEASE
#else
#if canImport(os)
import Foundation
import os
Expand All @@ -53,8 +55,15 @@ func runtimeWarn(
// To work around this, we hook into SwiftUI's runtime issue delivery mechanism, instead.
//
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc
@usableFromInline
let dso = { () -> UnsafeMutableRawPointer in
#if swift(>=5.10)
@usableFromInline
nonisolated(unsafe) let dso = getSwiftUIDSO()
#else
@usableFromInline
let dso = getSwiftUIDSO()
#endif

private func getSwiftUIDSO() -> UnsafeMutableRawPointer {
let count = _dyld_image_count()
for i in 0..<count {
if let name = _dyld_get_image_name(i) {
Expand All @@ -67,7 +76,7 @@ func runtimeWarn(
}
}
return UnsafeMutableRawPointer(mutating: #dsohandle)
}()
}
#elseif os(WASI)
#if canImport(JavaScriptCore)
import JavaScriptCore
Expand Down

0 comments on commit 00bc30c

Please sign in to comment.