Skip to content

Commit fbfb245

Browse files
authored
Revert #2033 (#2044)
* Revert #2033 See pointfreeco/swift-dependencies#83 for more info. * wip
1 parent 2537444 commit fbfb245

File tree

14 files changed

+286
-25
lines changed

14 files changed

+286
-25
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

Package.resolved

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

Package.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "0.14.0"),
2424
.package(url: "https://github.com/apple/swift-collections", from: "1.0.2"),
2525
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.10.0"),
26-
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.4.0"),
26+
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.4.1"),
2727
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "0.7.0"),
2828
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.7.1"),
2929
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "0.8.4"),
@@ -32,20 +32,21 @@ let package = Package(
3232
.target(
3333
name: "ComposableArchitecture",
3434
dependencies: [
35-
.product(name: "_SwiftUINavigationState", package: "swiftui-navigation"),
3635
.product(name: "CasePaths", package: "swift-case-paths"),
3736
.product(name: "CombineSchedulers", package: "combine-schedulers"),
3837
.product(name: "CustomDump", package: "swift-custom-dump"),
3938
.product(name: "Dependencies", package: "swift-dependencies"),
4039
.product(name: "IdentifiedCollections", package: "swift-identified-collections"),
4140
.product(name: "OrderedCollections", package: "swift-collections"),
41+
.product(name: "_SwiftUINavigationState", package: "swiftui-navigation"),
4242
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
4343
]
4444
),
4545
.testTarget(
4646
name: "ComposableArchitectureTests",
4747
dependencies: [
48-
"ComposableArchitecture"
48+
"_CAsyncSupport",
49+
"ComposableArchitecture",
4950
]
5051
),
5152
.executableTarget(
@@ -55,6 +56,7 @@ let package = Package(
5556
.product(name: "Benchmark", package: "swift-benchmark"),
5657
]
5758
),
59+
.systemLibrary(name: "_CAsyncSupport"),
5860
]
5961
)
6062

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift Async Algorithms open source project
4+
//
5+
// Copyright (c) 2022 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
//
10+
//===----------------------------------------------------------------------===//
11+
12+
#include <stdint.h>
13+
14+
#if !defined(__has_feature)
15+
#define __has_feature(x) 0
16+
#endif
17+
18+
#if !defined(__has_attribute)
19+
#define __has_attribute(x) 0
20+
#endif
21+
22+
#if !defined(__has_builtin)
23+
#define __has_builtin(builtin) 0
24+
#endif
25+
26+
#if !defined(__has_cpp_attribute)
27+
#define __has_cpp_attribute(attribute) 0
28+
#endif
29+
30+
// TODO: These macro definitions are duplicated in BridgedSwiftObject.h. Move
31+
// them to a single file if we find a location that both Visibility.h and
32+
// BridgedSwiftObject.h can import.
33+
#if __has_feature(nullability)
34+
// Provide macros to temporarily suppress warning about the use of
35+
// _Nullable and _Nonnull.
36+
# define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS \
37+
_Pragma("clang diagnostic push") \
38+
_Pragma("clang diagnostic ignored \"-Wnullability-extension\"")
39+
# define SWIFT_END_NULLABILITY_ANNOTATIONS \
40+
_Pragma("clang diagnostic pop")
41+
42+
#else
43+
// #define _Nullable and _Nonnull to nothing if we're not being built
44+
// with a compiler that supports them.
45+
# define _Nullable
46+
# define _Nonnull
47+
# define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
48+
# define SWIFT_END_NULLABILITY_ANNOTATIONS
49+
#endif
50+
51+
#define SWIFT_MACRO_CONCAT(A, B) A ## B
52+
#define SWIFT_MACRO_IF_0(IF_TRUE, IF_FALSE) IF_FALSE
53+
#define SWIFT_MACRO_IF_1(IF_TRUE, IF_FALSE) IF_TRUE
54+
#define SWIFT_MACRO_IF(COND, IF_TRUE, IF_FALSE) \
55+
SWIFT_MACRO_CONCAT(SWIFT_MACRO_IF_, COND)(IF_TRUE, IF_FALSE)
56+
57+
#if __has_attribute(pure)
58+
#define SWIFT_READONLY __attribute__((__pure__))
59+
#else
60+
#define SWIFT_READONLY
61+
#endif
62+
63+
#if __has_attribute(const)
64+
#define SWIFT_READNONE __attribute__((__const__))
65+
#else
66+
#define SWIFT_READNONE
67+
#endif
68+
69+
#if __has_attribute(always_inline)
70+
#define SWIFT_ALWAYS_INLINE __attribute__((always_inline))
71+
#else
72+
#define SWIFT_ALWAYS_INLINE
73+
#endif
74+
75+
#if __has_attribute(noinline)
76+
#define SWIFT_NOINLINE __attribute__((__noinline__))
77+
#else
78+
#define SWIFT_NOINLINE
79+
#endif
80+
81+
#if __has_attribute(noreturn)
82+
#define SWIFT_NORETURN __attribute__((__noreturn__))
83+
#else
84+
#define SWIFT_NORETURN
85+
#endif
86+
87+
#if __has_attribute(used)
88+
#define SWIFT_USED __attribute__((__used__))
89+
#else
90+
#define SWIFT_USED
91+
#endif
92+
93+
#if __has_attribute(unavailable)
94+
#define SWIFT_ATTRIBUTE_UNAVAILABLE __attribute__((__unavailable__))
95+
#else
96+
#define SWIFT_ATTRIBUTE_UNAVAILABLE
97+
#endif
98+
99+
#if (__has_attribute(weak_import))
100+
#define SWIFT_WEAK_IMPORT __attribute__((weak_import))
101+
#else
102+
#define SWIFT_WEAK_IMPORT
103+
#endif
104+
105+
// Define the appropriate attributes for sharing symbols across
106+
// image (executable / shared-library) boundaries.
107+
//
108+
// SWIFT_ATTRIBUTE_FOR_EXPORTS will be placed on declarations that
109+
// are known to be exported from the current image. Typically, they
110+
// are placed on header declarations and then inherited by the actual
111+
// definitions.
112+
//
113+
// SWIFT_ATTRIBUTE_FOR_IMPORTS will be placed on declarations that
114+
// are known to be exported from a different image. This never
115+
// includes a definition.
116+
//
117+
// Getting the right attribute on a declaratioon can be pretty awkward,
118+
// but it's necessary under the C translation model. All of this
119+
// ceremony is familiar to Windows programmers; C/C++ programmers
120+
// everywhere else usually don't bother, but since we have to get it
121+
// right for Windows, we have everything set up to get it right on
122+
// other targets as well, and doing so lets the compiler use more
123+
// efficient symbol access patterns.
124+
#if defined(__MACH__) || defined(__wasi__)
125+
126+
// On Mach-O and WebAssembly, we use non-hidden visibility. We just use
127+
// default visibility on both imports and exports, both because these
128+
// targets don't support protected visibility but because they don't
129+
// need it: symbols are not interposable outside the current image
130+
// by default.
131+
# define SWIFT_ATTRIBUTE_FOR_EXPORTS __attribute__((__visibility__("default")))
132+
# define SWIFT_ATTRIBUTE_FOR_IMPORTS __attribute__((__visibility__("default")))
133+
134+
#elif defined(__ELF__)
135+
136+
// On ELF, we use non-hidden visibility. For exports, we must use
137+
// protected visibility to tell the compiler and linker that the symbols
138+
// can't be interposed outside the current image. For imports, we must
139+
// use default visibility because protected visibility guarantees that
140+
// the symbol is defined in the current library, which isn't true for
141+
// an import.
142+
//
143+
// The compiler does assume that the runtime and standard library can
144+
// refer to each other's symbols as DSO-local, so it's important that
145+
// we get this right or we can get linker errors.
146+
# define SWIFT_ATTRIBUTE_FOR_EXPORTS __attribute__((__visibility__("protected")))
147+
# define SWIFT_ATTRIBUTE_FOR_IMPORTS __attribute__((__visibility__("default")))
148+
149+
#elif defined(__CYGWIN__)
150+
151+
// For now, we ignore all this on Cygwin.
152+
# define SWIFT_ATTRIBUTE_FOR_EXPORTS
153+
# define SWIFT_ATTRIBUTE_FOR_IMPORTS
154+
155+
// FIXME: this #else should be some sort of #elif Windows
156+
#else // !__MACH__ && !__ELF__
157+
158+
// On PE/COFF, we use dllimport and dllexport.
159+
# define SWIFT_ATTRIBUTE_FOR_EXPORTS __declspec(dllexport)
160+
# define SWIFT_ATTRIBUTE_FOR_IMPORTS __declspec(dllimport)
161+
162+
#endif
163+
164+
// CMake conventionally passes -DlibraryName_EXPORTS when building
165+
// code that goes into libraryName. This isn't the best macro name,
166+
// but it's conventional. We do have to pass it explicitly in a few
167+
// places in the build system for a variety of reasons.
168+
//
169+
// Unfortunately, defined(D) is a special function you can use in
170+
// preprocessor conditions, not a macro you can use anywhere, so we
171+
// need to manually check for all the libraries we know about so that
172+
// we can use them in our condition below.s
173+
#if defined(swiftCore_EXPORTS)
174+
#define SWIFT_IMAGE_EXPORTS_swiftCore 1
175+
#else
176+
#define SWIFT_IMAGE_EXPORTS_swiftCore 0
177+
#endif
178+
#if defined(swift_Concurrency_EXPORTS)
179+
#define SWIFT_IMAGE_EXPORTS_swift_Concurrency 1
180+
#else
181+
#define SWIFT_IMAGE_EXPORTS_swift_Concurrency 0
182+
#endif
183+
#if defined(swift_Distributed_EXPORTS)
184+
#define SWIFT_IMAGE_EXPORTS_swift_Distributed 1
185+
#else
186+
#define SWIFT_IMAGE_EXPORTS_swift_Distributed 0
187+
#endif
188+
#if defined(swift_Differentiation_EXPORTS)
189+
#define SWIFT_IMAGE_EXPORTS_swift_Differentiation 1
190+
#else
191+
#define SWIFT_IMAGE_EXPORTS_swift_Differentiation 0
192+
#endif
193+
194+
#define SWIFT_EXPORT_FROM_ATTRIBUTE(LIBRARY) \
195+
SWIFT_MACRO_IF(SWIFT_IMAGE_EXPORTS_##LIBRARY, \
196+
SWIFT_ATTRIBUTE_FOR_EXPORTS, \
197+
SWIFT_ATTRIBUTE_FOR_IMPORTS)
198+
199+
// SWIFT_EXPORT_FROM(LIBRARY) declares something to be a C-linkage
200+
// entity exported by the given library.
201+
//
202+
// SWIFT_RUNTIME_EXPORT is just SWIFT_EXPORT_FROM(swiftCore).
203+
//
204+
// TODO: use this in shims headers in overlays.
205+
#if defined(__cplusplus)
206+
#define SWIFT_EXPORT_FROM(LIBRARY) extern "C" SWIFT_EXPORT_FROM_ATTRIBUTE(LIBRARY)
207+
#define SWIFT_EXPORT extern "C"
208+
#else
209+
#define SWIFT_EXPORT extern
210+
#define SWIFT_EXPORT_FROM(LIBRARY) SWIFT_EXPORT_FROM_ATTRIBUTE(LIBRARY)
211+
#endif
212+
#define SWIFT_RUNTIME_EXPORT SWIFT_EXPORT_FROM(swiftCore)
213+
214+
// Define mappings for calling conventions.
215+
216+
// Annotation for specifying a calling convention of
217+
// a runtime function. It should be used with declarations
218+
// of runtime functions like this:
219+
// void runtime_function_name() SWIFT_CC(swift)
220+
#define SWIFT_CC(CC) SWIFT_CC_##CC
221+
222+
// SWIFT_CC(c) is the C calling convention.
223+
#define SWIFT_CC_c
224+
225+
// SWIFT_CC(swift) is the Swift calling convention.
226+
// FIXME: the next comment is false.
227+
// Functions outside the stdlib or runtime that include this file may be built
228+
// with a compiler that doesn't support swiftcall; don't define these macros
229+
// in that case so any incorrect usage is caught.
230+
#if __has_attribute(swiftcall)
231+
#define SWIFT_CC_swift __attribute__((swiftcall))
232+
#define SWIFT_CONTEXT __attribute__((swift_context))
233+
#define SWIFT_ERROR_RESULT __attribute__((swift_error_result))
234+
#define SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result))
235+
#else
236+
#define SWIFT_CC_swift
237+
#define SWIFT_CONTEXT
238+
#define SWIFT_ERROR_RESULT
239+
#define SWIFT_INDIRECT_RESULT
240+
#endif
241+
242+
typedef struct _Job* JobRef;
243+
244+
typedef SWIFT_CC(swift) void (*swift_task_enqueueGlobal_original)(JobRef _Nonnull job);
245+
SWIFT_EXPORT_FROM(swift_Concurrency)
246+
SWIFT_CC(swift) void (* _Nullable swift_task_enqueueGlobal_hook)(
247+
JobRef _Nonnull job, swift_task_enqueueGlobal_original _Nonnull original);
248+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module _CAsyncSupport [system] {
2+
header "_CAsyncSupport.h"
3+
export *
4+
}

Tests/ComposableArchitectureTests/ComposableArchitectureTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Combine
22
import CombineSchedulers
33
import ComposableArchitecture
4-
@_spi(Concurrency) import Dependencies
54
import XCTest
65

76
@MainActor
@@ -113,7 +112,7 @@ final class ComposableArchitectureTests: BaseTCATestCase {
113112
}
114113

115114
func testCancellation() async {
116-
await withMainSerialExecutor {
115+
await _withMainSerialExecutor {
117116
let mainQueue = DispatchQueue.test
118117

119118
enum Action: Equatable {

Tests/ComposableArchitectureTests/EffectRunTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class EffectRunTests: BaseTCATestCase {
4444

4545
#if DEBUG
4646
func testRunUnhandledFailure() async {
47-
await withMainSerialExecutor {
47+
await _withMainSerialExecutor {
4848
var line: UInt!
4949
XCTExpectFailure(nil, enabled: nil, strict: nil) {
5050
$0.compactDescription == """
@@ -123,7 +123,7 @@ final class EffectRunTests: BaseTCATestCase {
123123

124124
#if DEBUG
125125
func testRunEscapeFailure() async throws {
126-
try await withMainSerialExecutor {
126+
try await _withMainSerialExecutor {
127127
XCTExpectFailure {
128128
$0.compactDescription == """
129129
An action was sent from a completed effect:

Tests/ComposableArchitectureTests/EffectTests.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Combine
22
@_spi(Canary)@_spi(Internals) import ComposableArchitecture
3-
@_spi(Concurrency) import Dependencies
43
import XCTest
54

65
@MainActor
@@ -53,7 +52,7 @@ final class EffectTests: BaseTCATestCase {
5352

5453
#if swift(>=5.7) && (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst))
5554
func testConcatenate() async {
56-
await withMainSerialExecutor {
55+
await _withMainSerialExecutor {
5756
if #available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) {
5857
let clock = TestClock()
5958
var values: [Int] = []
@@ -108,7 +107,7 @@ final class EffectTests: BaseTCATestCase {
108107
#if swift(>=5.7) && (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst))
109108
func testMerge() async {
110109
if #available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) {
111-
await withMainSerialExecutor {
110+
await _withMainSerialExecutor {
112111
let clock = TestClock()
113112

114113
let effect = EffectPublisher<Int, Never>.merge(
@@ -308,7 +307,7 @@ final class EffectTests: BaseTCATestCase {
308307
}
309308

310309
func testDependenciesTransferredToEffects_Run() async {
311-
await withMainSerialExecutor {
310+
await _withMainSerialExecutor {
312311
struct Feature: ReducerProtocol {
313312
enum Action: Equatable {
314313
case tap

0 commit comments

Comments
 (0)