Commit d2a1019
authored
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.1 parent 69a1e26 commit d2a1019
File tree
4 files changed
+48
-33
lines changed- Sources/TestingMacros
- Support
- Additions
- Tests/TestingMacrosTests
4 files changed
+48
-33
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
324 | 326 | | |
325 | 327 | | |
326 | | - | |
| 328 | + | |
327 | 329 | | |
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
331 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
332 | 337 | | |
333 | | - | |
| 338 | + | |
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
337 | 342 | | |
338 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
339 | 347 | | |
340 | 348 | | |
341 | 349 | | |
342 | 350 | | |
343 | 351 | | |
344 | 352 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
| 353 | + | |
351 | 354 | | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
| 355 | + | |
358 | 356 | | |
359 | 357 | | |
360 | | - | |
361 | | - | |
| 358 | + | |
| 359 | + | |
362 | 360 | | |
363 | | - | |
| 361 | + | |
364 | 362 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | 363 | | |
372 | | - | |
373 | | - | |
| 364 | + | |
| 365 | + | |
374 | 366 | | |
375 | | - | |
| 367 | + | |
376 | 368 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
383 | 375 | | |
384 | 376 | | |
385 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
121 | 137 | | |
122 | 138 | | |
123 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
| |||
0 commit comments