Skip to content

Commit 5d87dda

Browse files
authored
Perception 2.0 (#176)
* Perception 2.0 * Update Package.resolved * wip * wip * Perception 2.0.0 * wip
1 parent 198ec7e commit 5d87dda

File tree

6 files changed

+63
-56
lines changed

6 files changed

+63
-56
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: macOS
1919
strategy:
2020
matrix:
21-
xcode: ['16.1']
21+
xcode: ['16.4']
2222
config: ['debug', 'release']
2323
runs-on: macos-15
2424
steps:
@@ -41,34 +41,20 @@ jobs:
4141
- name: Build
4242
run: swift build
4343

44-
wasm:
45-
name: Wasm
46-
runs-on: ubuntu-latest
47-
steps:
48-
- uses: actions/checkout@v4
49-
- uses: bytecodealliance/actions/wasmtime/setup@v1
50-
- name: Install Swift and Swift SDK for WebAssembly
51-
run: |
52-
PREFIX=/opt/swift
53-
set -ex
54-
curl -f -o /tmp/swift.tar.gz "https://download.swift.org/swift-6.0.3-release/ubuntu2204/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu22.04.tar.gz"
55-
sudo mkdir -p $PREFIX; sudo tar -xzf /tmp/swift.tar.gz -C $PREFIX --strip-component 1
56-
$PREFIX/usr/bin/swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.3-RELEASE/swift-wasm-6.0.3-RELEASE-wasm32-unknown-wasi.artifactbundle.zip --checksum 31d3585b06dd92de390bacc18527801480163188cd7473f492956b5e213a8618
57-
echo "$PREFIX/usr/bin" >> $GITHUB_PATH
58-
59-
- name: Build
60-
run: swift build --swift-sdk wasm32-unknown-wasi -Xlinker -z -Xlinker stack-size=$((1024 * 1024))
61-
62-
compatibility:
63-
name: Compatibility
64-
strategy:
65-
matrix:
66-
xcode: ['15.2']
67-
config: ['debug', 'release']
68-
runs-on: macos-14
69-
steps:
70-
- uses: actions/checkout@v4
71-
- name: Select Xcode ${{ matrix.xcode }}
72-
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
73-
- name: Run ${{ matrix.config }} tests
74-
run: swift build -c ${{ matrix.config }}
44+
# wasm:
45+
# name: Wasm
46+
# runs-on: ubuntu-latest
47+
# steps:
48+
# - uses: actions/checkout@v4
49+
# - uses: bytecodealliance/actions/wasmtime/setup@v1
50+
# - name: Install Swift and Swift SDK for WebAssembly
51+
# run: |
52+
# PREFIX=/opt/swift
53+
# set -ex
54+
# curl -f -o /tmp/swift.tar.gz "https://download.swift.org/swift-6.0.3-release/ubuntu2204/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu22.04.tar.gz"
55+
# sudo mkdir -p $PREFIX; sudo tar -xzf /tmp/swift.tar.gz -C $PREFIX --strip-component 1
56+
# $PREFIX/usr/bin/swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.3-RELEASE/swift-wasm-6.0.3-RELEASE-wasm32-unknown-wasi.artifactbundle.zip --checksum 31d3585b06dd92de390bacc18527801480163188cd7473f492956b5e213a8618
57+
# echo "$PREFIX/usr/bin" >> $GITHUB_PATH
58+
#
59+
# - name: Build
60+
# run: swift build --swift-sdk wasm32-unknown-wasi -Xlinker -z -Xlinker stack-size=$((1024 * 1024))

Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let package = Package(
2222
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.0.0"),
2323
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.5.1"),
2424
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.0.0"),
25-
.package(url: "https://github.com/pointfreeco/swift-perception", from: "1.4.1"),
25+
.package(url: "https://github.com/pointfreeco/swift-perception", "1.4.1"..<"3.0.0"),
2626
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.4.3"),
2727
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
2828
],

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let package = Package(
2222
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.0.0"),
2323
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.5.1"),
2424
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.0.0"),
25-
.package(url: "https://github.com/pointfreeco/swift-perception", from: "1.4.1"),
25+
.package(url: "https://github.com/pointfreeco/swift-perception", "1.4.1"..<"3.0.0"),
2626
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.4.3"),
2727
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
2828
],

Sources/Sharing/Shared.swift

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -412,27 +412,38 @@ extension Shared: CustomStringConvertible {
412412

413413
extension Shared: Equatable where Value: Equatable {
414414
public static func == (lhs: Self, rhs: Self) -> Bool {
415-
func openLhs<T: MutableReference<Value>>(_ lhsReference: T) -> Bool {
416-
// NB: iOS <16 does not support casting this existential, so we must open it explicitly
417-
func openRhs<S: MutableReference<Value>>(_ rhsReference: S) -> Bool {
418-
lhsReference == rhsReference as? T
415+
// TODO: Explore 'isTesting ? (check snapshot against value) : lhs.reference == rhs.reference
416+
func isEqual() -> Bool {
417+
func openLhs<T: MutableReference<Value>>(_ lhsReference: T) -> Bool {
418+
// NB: iOS <16 does not support casting this existential, so we must open it explicitly
419+
func openRhs<S: MutableReference<Value>>(_ rhsReference: S) -> Bool {
420+
lhsReference == rhsReference as? T
421+
}
422+
return openRhs(rhs.reference)
423+
}
424+
@Dependency(\.snapshots) var snapshots
425+
if snapshots.isAsserting, openLhs(lhs.reference) {
426+
snapshots.untrack(lhs.reference)
427+
return lhs.wrappedValue == rhs.reference.wrappedValue
428+
} else {
429+
return lhs.wrappedValue == rhs.wrappedValue
419430
}
420-
return openRhs(rhs.reference)
421-
}
422-
@Dependency(\.snapshots) var snapshots
423-
if snapshots.isAsserting, openLhs(lhs.reference) {
424-
snapshots.untrack(lhs.reference)
425-
return lhs.wrappedValue == rhs.reference.wrappedValue
426-
} else {
427-
return lhs.wrappedValue == rhs.wrappedValue
428431
}
429-
// TODO: Explore 'isTesting ? (check snapshot against value) : lhs.reference == rhs.reference
432+
#if DEBUG
433+
return _PerceptionLocals.$skipPerceptionChecking.withValue(true, operation: isEqual)
434+
#else
435+
return isEqual()
436+
#endif
430437
}
431438
}
432439

433440
extension Shared: Identifiable where Value: Identifiable {
434441
public var id: Value.ID {
435-
wrappedValue.id
442+
#if DEBUG
443+
_PerceptionLocals.$skipPerceptionChecking.withValue(true) { wrappedValue.id }
444+
#else
445+
wrappedValue.id
446+
#endif
436447
}
437448
}
438449

Sources/Sharing/SharedReader.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,23 @@ extension SharedReader: CustomStringConvertible {
301301

302302
extension SharedReader: Equatable where Value: Equatable {
303303
public static func == (lhs: Self, rhs: Self) -> Bool {
304-
lhs.wrappedValue == rhs.wrappedValue
304+
#if DEBUG
305+
_PerceptionLocals.$skipPerceptionChecking.withValue(true) {
306+
lhs.wrappedValue == rhs.wrappedValue
307+
}
308+
#else
309+
lhs.wrappedValue == rhs.wrappedValue
310+
#endif
305311
}
306312
}
307313

308314
extension SharedReader: Identifiable where Value: Identifiable {
309315
public var id: Value.ID {
310-
wrappedValue.id
316+
#if DEBUG
317+
_PerceptionLocals.$skipPerceptionChecking.withValue(true) { wrappedValue.id }
318+
#else
319+
wrappedValue.id
320+
#endif
311321
}
312322
}
313323

0 commit comments

Comments
 (0)