Skip to content

🍒 [6.1.1] Fully-qualify reference to Swift's Actor protocol in macro expansion code for synchronous test functions #1071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

stmontgomery
Copy link
Contributor

…n code for synchronous test functions (swiftlang#1067)

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`. For example, the
following code reproduces the error:

```swift
// In MyApp
public class Actor {}

// In test code
import Testing
import MyApp

// ❌ 'any' has no effect on concrete type 'Actor'
//  - 'isolated' parameter type 'Actor?' does not conform to 'Actor' or 'DistributedActor'
@test func example() /* No 'async' */ {}
```

The macro code includes an unqualified reference to a type by that name,
but it's intended to refer to the protocol in Swift's `_Concurrency`
module. The fix is to ensure the macro's reference to this protocol is
fully-qualified with a module name.

This was first reported on the Swift Forums in
https://forums.swift.org/t/error-isolated-parameter-type-actor-does-not-conform-to-actor-or-distributedactor/79190.
This bug was introduced in swiftlang#747, which first landed in Swift 6.1 and
Xcode 16.3.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
@stmontgomery stmontgomery added bug 🪲 Something isn't working macros 🔭 Related to Swift macros such as @Test or #expect labels Apr 11, 2025
@stmontgomery stmontgomery added this to the 6.1.1 milestone Apr 11, 2025
@stmontgomery stmontgomery self-assigned this Apr 11, 2025
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery stmontgomery merged commit 32cf2c5 into swiftlang:release/6.1.1 Apr 11, 2025
3 checks passed
@stmontgomery stmontgomery deleted the 6.1.1-actor-disambiguation branch April 11, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working macros 🔭 Related to Swift macros such as @Test or #expect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants