Skip to content

Commit 32cf2c5

Browse files
authored
🍒 [6.1.1] Fully-qualify reference to Swift's Actor protocol in macro expansion code for synchronous test functions (#1071)
- **Explanation**: This fixes a compilation error in code expanded from the `@Test` macro when it's attached to a synchronous (i.e. non-`async`) test function in a context where there is a concrete type named `Actor`. - **Scope**: Affects tests in code which also has a custom type named `Actor`. - **Issues**: n/a - **Original PRs**: #1067 - **Risk**: Low - **Testing**: Modified tests to detect this. - **Reviewers**: @grynspan
1 parent 3a02a1d commit 32cf2c5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

‎Sources/TestingMacros/TestDeclarationMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public struct TestDeclarationMacro: PeerMacro, Sendable {
333333
}
334334
FunctionParameterSyntax(
335335
firstName: .wildcardToken(),
336-
type: "isolated (any Actor)?" as TypeSyntax,
336+
type: "isolated (any _Concurrency.Actor)?" as TypeSyntax,
337337
defaultValue: InitializerClauseSyntax(value: "Testing.__defaultSynchronousIsolationContext" as ExprSyntax)
338338
)
339339
}

‎Tests/TestingTests/MiscellaneousTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ struct SendableTests: Sendable {
137137
@Suite("Named Sendable test type", .hidden)
138138
struct NamedSendableTests: Sendable {}
139139

140+
// This is meant to help detect unqualified usages of the `Actor` protocol from
141+
// Swift's `_Concurrency` module in macro expansion code, since it's possible
142+
// for another module to declare a type with that name.
143+
private class Actor {}
144+
140145
#if !SWT_NO_GLOBAL_ACTORS
141146
@Suite(.hidden)
142147
@MainActor

0 commit comments

Comments
 (0)