Skip to content

Commit 7b72dcd

Browse files
committed
Move a big explanatory comment to the main target
1 parent dfb61b4 commit 7b72dcd

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,6 @@ private import CoreGraphics
1414

1515
private import UniformTypeIdentifiers
1616

17-
/// ## Why can't images directly conform to Attachable?
18-
///
19-
/// Three reasons:
20-
///
21-
/// 1. Several image classes are not marked `Sendable`, which means that as far
22-
/// as Swift is concerned, they cannot be safely passed to Swift Testing's
23-
/// event handler (primarily because `Event` is `Sendable`.) So we would have
24-
/// to eagerly serialize them, which is unnecessarily expensive if we know
25-
/// they're actually concurrency-safe.
26-
/// 2. We would have no place to store metadata such as the encoding quality
27-
/// (although in the future we may introduce a "metadata" associated type to
28-
/// `Attachable` that could store that info.)
29-
/// 3. `Attachable` has a requirement with `Self` in non-parameter, non-return
30-
/// position. As far as Swift is concerned, a non-final class cannot satisfy
31-
/// such a requirement, and all image types we care about are non-final
32-
/// classes. Thus, the compiler will steadfastly refuse to allow non-final
33-
/// classes to conform to the `Attachable` protocol. We could get around this
34-
/// by changing the signature of `withUnsafeBytes()` so that the
35-
/// generic parameter to `Attachment` is not `Self`, but that would defeat
36-
/// much of the purpose of making `Attachment` generic in the first place.
37-
/// (And no, the language does not let us write `where T: Self` anywhere
38-
/// useful.)
39-
4017
@available(_uttypesAPI, *)
4118
extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsImage {
4219
/// Get the image format to use when encoding an image, substituting a

Sources/Testing/Attachments/Images/AttachableAsImage.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@
1414
#error("Platform-specific misconfiguration: support for image attachments requires a platform-specific implementation")
1515
#endif
1616

17+
/// ## Why can't images directly conform to Attachable?
18+
///
19+
/// Three reasons:
20+
///
21+
/// 1. Several image classes are not marked `Sendable`, which means that as far
22+
/// as Swift is concerned, they cannot be safely passed to Swift Testing's
23+
/// event handler (primarily because `Event` is `Sendable`.) So we would have
24+
/// to eagerly serialize them, which is unnecessarily expensive if we know
25+
/// they're actually concurrency-safe.
26+
/// 2. We would have no place to store metadata such as the encoding quality
27+
/// (although in the future we may introduce a "metadata" associated type to
28+
/// `Attachable` that could store that info.)
29+
/// 3. `Attachable` has a requirement with `Self` in non-parameter, non-return
30+
/// position. As far as Swift is concerned, a non-final class cannot satisfy
31+
/// such a requirement, and all image types we care about are non-final
32+
/// classes. Thus, the compiler will steadfastly refuse to allow non-final
33+
/// classes to conform to the `Attachable` protocol. We could get around this
34+
/// by changing the signature of `withUnsafeBytes()` so that the
35+
/// generic parameter to `Attachment` is not `Self`, but that would defeat
36+
/// much of the purpose of making `Attachment` generic in the first place.
37+
/// (And no, the language does not let us write `where T: Self` anywhere
38+
/// useful.)
39+
1740
/// A protocol describing images that can be converted to instances of
1841
/// [`Attachment`](https://developer.apple.com/documentation/testing/attachment).
1942
///

0 commit comments

Comments
 (0)