Skip to content

Commit beee8e6

Browse files
committed
feat(Swift 6.0): Prepare package for swift update
1 parent af5dfc8 commit beee8e6

File tree

15 files changed

+173
-31
lines changed

15 files changed

+173
-31
lines changed

.github/package.xcworkspace/xcshareddata/swiftpm/Package.resolved

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33
{
44
"identity" : "swift-macro-testing",
55
"kind" : "remoteSourceControl",
6-
"location" : "https://github.com/pointfreeco/swift-macro-testing.git",
6+
"location" : "https://github.com/pointfreeco/swift-macro-testing",
77
"state" : {
8-
"revision" : "10dcef36314ddfea6f60442169b0b320204cbd35",
9-
"version" : "0.2.2"
8+
"revision" : "20c1a8f3b624fb5d1503eadcaa84743050c350f4",
9+
"version" : "0.5.2"
1010
}
1111
},
1212
{
1313
"identity" : "swift-macro-toolkit",
1414
"kind" : "remoteSourceControl",
1515
"location" : "https://github.com/stackotter/swift-macro-toolkit.git",
1616
"state" : {
17-
"revision" : "106daeb38eb3f52b1540aed981fc63fa22274576",
18-
"version" : "0.3.1"
17+
"revision" : "2eded9c9a98cba42d70fb179d516231fffcff1e4",
18+
"version" : "0.5.0"
1919
}
2020
},
2121
{
2222
"identity" : "swift-snapshot-testing",
2323
"kind" : "remoteSourceControl",
2424
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
2525
"state" : {
26-
"revision" : "8e68404f641300bfd0e37d478683bb275926760c",
27-
"version" : "1.15.2"
26+
"revision" : "7b0bbbae90c41f848f90ac7b4df6c4f50068256d",
27+
"version" : "1.17.5"
2828
}
2929
},
3030
{
3131
"identity" : "swift-syntax",
3232
"kind" : "remoteSourceControl",
33-
"location" : "https://github.com/apple/swift-syntax.git",
33+
"location" : "https://github.com/swiftlang/swift-syntax",
3434
"state" : {
35-
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
36-
"version" : "509.0.0"
35+
"revision" : "2bc86522d115234d1f588efe2bcb4ce4be8f8b82",
36+
"version" : "510.0.3"
3737
}
3838
}
3939
],

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ DerivedData/
66
.swiftpm/configuration/registries.json
77
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
88
.netrc
9+
Package.resolved

.spi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ version: 1
22
builder:
33
configs:
44
- documentation_targets: [Interception]
5-
swift_version: 5.9
5+
swift_version: 5.10

Package.resolved

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
"kind" : "remoteSourceControl",
66
"location" : "https://github.com/pointfreeco/swift-macro-testing.git",
77
"state" : {
8-
"revision" : "10dcef36314ddfea6f60442169b0b320204cbd35",
9-
"version" : "0.2.2"
8+
"revision" : "20c1a8f3b624fb5d1503eadcaa84743050c350f4",
9+
"version" : "0.5.2"
1010
}
1111
},
1212
{
1313
"identity" : "swift-macro-toolkit",
1414
"kind" : "remoteSourceControl",
1515
"location" : "https://github.com/stackotter/swift-macro-toolkit.git",
1616
"state" : {
17-
"revision" : "106daeb38eb3f52b1540aed981fc63fa22274576",
18-
"version" : "0.3.1"
17+
"revision" : "2eded9c9a98cba42d70fb179d516231fffcff1e4",
18+
"version" : "0.5.0"
1919
}
2020
},
2121
{
2222
"identity" : "swift-snapshot-testing",
2323
"kind" : "remoteSourceControl",
2424
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
2525
"state" : {
26-
"revision" : "8e68404f641300bfd0e37d478683bb275926760c",
27-
"version" : "1.15.2"
26+
"revision" : "7b0bbbae90c41f848f90ac7b4df6c4f50068256d",
27+
"version" : "1.17.5"
2828
}
2929
},
3030
{
3131
"identity" : "swift-syntax",
3232
"kind" : "remoteSourceControl",
33-
"location" : "https://github.com/apple/swift-syntax.git",
33+
"location" : "https://github.com/swiftlang/swift-syntax",
3434
"state" : {
35-
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
36-
"version" : "509.0.0"
35+
"revision" : "2bc86522d115234d1f588efe2bcb4ce4be8f8b82",
36+
"version" : "510.0.3"
3737
}
3838
}
3939
],

Package.swift

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.9
1+
// swift-tools-version:5.10
22

33
import PackageDescription
44
import CompilerPluginSupport
@@ -10,7 +10,7 @@ let package = Package(
1010
.macOS(.v10_15),
1111
.tvOS(.v13),
1212
.macCatalyst(.v13),
13-
.watchOS(.v6)
13+
.watchOS(.v6),
1414
],
1515
products: [
1616
.library(
@@ -42,11 +42,11 @@ let package = Package(
4242
dependencies: [
4343
.package(
4444
url: "https://github.com/stackotter/swift-macro-toolkit.git",
45-
.upToNextMinor(from: "0.3.0")
45+
.upToNextMinor(from: "0.5.0")
4646
),
4747
.package(
4848
url: "https://github.com/pointfreeco/swift-macro-testing.git",
49-
.upToNextMinor(from: "0.2.2")
49+
.upToNextMinor(from: "0.5.0")
5050
)
5151
],
5252
targets: [
@@ -109,3 +109,12 @@ let package = Package(
109109
),
110110
]
111111
)
112+
113+
#if compiler(>=6)
114+
for target in package.targets where target.type != .system && target.type != .test {
115+
target.swiftSettings = target.swiftSettings ?? []
116+
target.swiftSettings?.append(contentsOf: [
117+
.enableUpcomingFeature("InferSendableFromCaptures")
118+
])
119+
}
120+
#endif

[email protected]

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// swift-tools-version:6.0
2+
3+
import PackageDescription
4+
import CompilerPluginSupport
5+
6+
let package = Package(
7+
name: "swift-interception",
8+
platforms: [
9+
.iOS(.v13),
10+
.macOS(.v10_15),
11+
.tvOS(.v13),
12+
.macCatalyst(.v13),
13+
.watchOS(.v6),
14+
],
15+
products: [
16+
.library(
17+
name: "_InterceptionCustomSelectors",
18+
type: .static,
19+
targets: ["_InterceptionCustomSelectors"]
20+
),
21+
.library(
22+
name: "_InterceptionMacros",
23+
type: .static,
24+
targets: ["_InterceptionMacros"]
25+
),
26+
.library(
27+
name: "_InterceptionUtils",
28+
type: .static,
29+
targets: ["_InterceptionUtils"]
30+
),
31+
.library(
32+
name: "Interception",
33+
type: .static,
34+
targets: ["Interception"]
35+
),
36+
.library(
37+
name: "InterceptionMacros",
38+
type: .static,
39+
targets: ["InterceptionMacros"]
40+
),
41+
],
42+
dependencies: [
43+
.package(
44+
url: "https://github.com/stackotter/swift-macro-toolkit.git",
45+
.upToNextMinor(from: "0.5.0")
46+
),
47+
.package(
48+
url: "https://github.com/pointfreeco/swift-macro-testing.git",
49+
.upToNextMinor(from: "0.5.2")
50+
)
51+
],
52+
targets: [
53+
.target(
54+
name: "_InterceptionMacros",
55+
dependencies: [
56+
.target(name: "InterceptionMacrosPlugin"),
57+
.target(name: "_InterceptionCustomSelectors")
58+
]
59+
),
60+
.target(name: "_InterceptionCustomSelectors"),
61+
.target(name: "_InterceptionUtilsObjc"),
62+
.target(
63+
name: "_InterceptionUtils",
64+
dependencies: [
65+
.target(name: "_InterceptionUtilsObjc"),
66+
]
67+
),
68+
.target(
69+
name: "Interception",
70+
dependencies: [
71+
.target(name: "_InterceptionCustomSelectors"),
72+
.target(name: "_InterceptionUtils"),
73+
]
74+
),
75+
.target(
76+
name: "InterceptionMacros",
77+
dependencies: [
78+
.target(name: "_InterceptionMacros"),
79+
.target(name: "Interception")
80+
]
81+
),
82+
.macro(
83+
name: "InterceptionMacrosPlugin",
84+
dependencies: [
85+
.product(
86+
name: "MacroToolkit",
87+
package: "swift-macro-toolkit"
88+
)
89+
]
90+
),
91+
.testTarget(
92+
name: "InterceptionMacrosPluginTests",
93+
dependencies: [
94+
.target(name: "InterceptionMacrosPlugin"),
95+
.product(name: "MacroTesting", package: "swift-macro-testing"),
96+
]
97+
),
98+
.testTarget(
99+
name: "InterceptionTests",
100+
dependencies: [
101+
.target(name: "Interception"),
102+
]
103+
),
104+
.testTarget(
105+
name: "InterceptionMacrosTests",
106+
dependencies: [
107+
.target(name: "InterceptionMacros"),
108+
]
109+
),
110+
],
111+
swiftLanguageModes: [.v6]
112+
)
113+
114+
for target in package.targets where target.type == .system || target.type == .test {
115+
target.swiftSettings?.append(contentsOf: [
116+
.swiftLanguageMode(.v5),
117+
.enableExperimentalFeature("StrictConcurrency"),
118+
.enableUpcomingFeature("InferSendableFromCaptures"),
119+
])
120+
}

Sources/Interception/NSObject+Interception.swift

+5
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ import _InterceptionCustomSelectors
55

66
/// Whether the runtime subclass has already been prepared for method
77
/// interception.
8+
nonisolated(unsafe)
89
private let interceptedKey = AssociationKey(default: false)
910

1011
/// Holds the method signature cache of the runtime subclass.
12+
nonisolated(unsafe)
1113
private let signatureCacheKey = AssociationKey<SignatureCache>()
1214

1315
/// Holds the method selector cache of the runtime subclass.
16+
nonisolated(unsafe)
1417
private let selectorCacheKey = AssociationKey<SelectorCache>()
1518

19+
nonisolated(unsafe)
1620
internal let noImplementation: IMP = unsafeBitCast(Int(0), to: IMP.self)
1721

1822
extension NSObject {
@@ -327,6 +331,7 @@ private func setupMethodSignatureCaching(_ realClass: AnyClass, _ signatureCache
327331

328332
@_spi(Internals)
329333
public struct SwiftInterceptionDefaultInterceptionHandlerKey: Hashable {
334+
nonisolated(unsafe)
330335
public static let shared: Self = .init()
331336

332337
private init() {}

Sources/InterceptionMacrosPlugin/Macros/MethodSelectorMacro.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public struct MethodSelectorMacro: ExpressionMacro {
1111
of node: Node,
1212
in context: Context
1313
) -> ExprSyntax {
14-
guard let arg = node.argumentList.first.map(\.expression)
14+
guard let arg = node.arguments.first.map(\.expression)
1515
else { fatalError("compiler bug: the macro does not have any arguments") }
1616

1717
return """

Sources/InterceptionMacrosPlugin/Macros/PropertySelectorMacro.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct PropertySelectorMacro: ExpressionMacro {
1010
of node: Node,
1111
in context: Context
1212
) -> ExprSyntax {
13-
guard let arg = node.argumentList.first.map(\.expression)
13+
guard let arg = node.arguments.first.map(\.expression)
1414
else { fatalError("compiler bug: the macro does not have any arguments") }
1515

1616
return """

Sources/_InterceptionUtils/ObjC+Constants.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ public enum ObjCSelector {
99

1010
// Method encoding of the unavailable selectors.
1111
public enum ObjCMethodEncoding {
12+
nonisolated(unsafe)
1213
public static let forwardInvocation = extract("v@:@")
14+
15+
nonisolated(unsafe)
1316
public static let methodSignatureForSelector = extract("v@::")
17+
18+
nonisolated(unsafe)
1419
public static let getClass = extract("#@:")
15-
20+
1621
private static func extract(_ string: StaticString) -> UnsafePointer<CChar> {
1722
return UnsafeRawPointer(string.utf8Start).assumingMemoryBound(to: CChar.self)
1823
}

Sources/_InterceptionUtils/ObjC+RuntimeSubclassing.swift

+2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import Combine
33
import Foundation
44

55
/// Whether the runtime subclass has already been swizzled.
6+
nonisolated(unsafe)
67
private let runtimeSubclassedKey = AssociationKey(default: false)
78

89
/// A known combine-interception runtime subclass of the instance. `nil` if the runtime subclass
910
/// has not been requested for the instance before.
11+
nonisolated(unsafe)
1012
private let knownRuntimeSubclassKey = AssociationKey<AnyClass?>(default: nil)
1113

1214
extension NSObject {

Tests/InterceptionMacrosPluginTests/MethodSelectorTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import InterceptionMacrosPlugin
55
final class MethodSelectorTests: XCTestCase {
66
override func invokeTest() {
77
withMacroTesting(
8-
isRecording: false,
8+
record: false,
99
macros: [
1010
"methodSelector": MethodSelectorMacro.self
1111
]

Tests/InterceptionMacrosPluginTests/PropertySelectorTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import InterceptionMacrosPlugin
55
final class PropertySelectorTests: XCTestCase {
66
override func invokeTest() {
77
withMacroTesting(
8-
isRecording: false,
8+
record: false,
99
macros: [
1010
"propertySelector": PropertySelectorMacro.self
1111
]

Tests/InterceptionMacrosTests/InterceptionMacrosTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ final class InterceptionMacrosTests: XCTestCase {
127127
}
128128
}
129129

130-
fileprivate class Object: NSObject {
130+
fileprivate final class Object: NSObject, Sendable {
131131
@discardableResult
132132
@objc dynamic
133133
func zero() -> Int { 0 }

Tests/InterceptionTests/InterceptionTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ final class InterceptionTests: XCTestCase {
142142
}
143143
}
144144

145-
fileprivate class Object: NSObject {
145+
fileprivate final class Object: NSObject, Sendable {
146146
@discardableResult
147147
@objc dynamic
148148
func zero() -> Int { 0 }

0 commit comments

Comments
 (0)