Skip to content

Commit e6de865

Browse files
authored
Add remove global actor isolation (#381)
1 parent af3286a commit e6de865

File tree

4 files changed

+60
-16
lines changed

4 files changed

+60
-16
lines changed

Sources/OpenSwiftUICore/Render/GeometryEffect/GeometryEffect.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package import OpenGraphShims
1616
/// The only change the effect makes to the view's ancestors and descendants is
1717
/// to change the coordinate transform to and from them.
1818
@available(OpenSwiftUI_v1_0, *)
19-
public protocol GeometryEffect: Animatable, ViewModifier where Body == Never {
19+
public protocol GeometryEffect: Animatable, ViewModifier, _RemoveGlobalActorIsolation where Body == Never {
2020
/// Returns the current value of the effect.
2121
func effectValue(size: CGSize) -> ProjectionTransform
2222

Sources/OpenSwiftUICore/Util/ImpossibleActor.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// _RemoveGlobalActor.swift
3+
// OpenSwiftUICore
4+
//
5+
// Audited for 6.5.4
6+
// Status: Complete
7+
// ID: E36588D6F4797F7C6EF26CC7E1C2D1CE
8+
9+
@globalActor
10+
public actor _ImpossibleActor: Sendable {
11+
public static var shared = _ImpossibleActor()
12+
13+
public nonisolated var unownedExecutor: UnownedSerialExecutor {
14+
_ImpossibleExecutor().asUnownedSerialExecutor()
15+
}
16+
}
17+
18+
private final class _ImpossibleExecutor: SerialExecutor {
19+
func enqueue(_ job: consuming ExecutorJob) {
20+
preconditionFailure("_RemoveGlobalActorIsolation is not intended to be used as a stand-alone protocol with a global actor isolation.")
21+
}
22+
}
23+
24+
@_marker
25+
@_ImpossibleActor
26+
public protocol _RemoveGlobalActorIsolation {}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// _RemoveGlobalActorTests.swift
3+
// OpenSwiftUICoreTests
4+
5+
import OpenSwiftUICore
6+
import Testing
7+
8+
// MARK: - _RemoveGlobalActorTests
9+
10+
struct _RemoveGlobalActorTests {
11+
@MainActor
12+
protocol P {}
13+
14+
@Test
15+
func removeGlobalActorIsolation() {
16+
struct A: P, _RemoveGlobalActorIsolation {
17+
static func p() {}
18+
}
19+
A.p()
20+
}
21+
22+
#if compiler(>=6.2)
23+
@Test
24+
func standaloneConstraintCrash() async {
25+
struct B: _RemoveGlobalActorIsolation {
26+
static func p() {}
27+
}
28+
await #expect(processExitsWith: .failure) {
29+
await B.p()
30+
}
31+
}
32+
#endif
33+
}

0 commit comments

Comments
 (0)