You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Diagnose when using a non-escapable type as suite. (#988)
This PR introduces a custom compile-time diagnostic when attempting to
use a non-escapable type as a suite. For example:
```swift
@suite struct NumberOfBeesTests: ~Escapable {
@test borrowing func countBees() { ... } // 🛑 Attribute 'Test' cannot be applied to a function within structure 'NumberOfBeesTests' because its conformance to 'Escapable' has been suppressed
}
```
Values with non-escapable type cannot currently be initialized nor
returned from a function, and we need to be able to do both in order to
correctly implement the `@Test` macro.
This change does not diagnose if `@Suite` is applied to such a type but
does not contain any test functions, because we do compile successfully
in that case and this sort of pattern remains valid:
```swift
@suite struct MyTests: ~Escapable {
@suite struct EndToEndTests {
...
}
}
```
### 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.
message:"Attribute \(_macroName(attribute)) cannot be applied to \(_kindString(for: decl, includeA:true)) within\(generic) function '\(functionName)'",
349
-
severity:.error
350
-
)
353
+
message +=" within\(generic) function '\(functionDecl.completeName)'"
0 commit comments