Skip to content

Commit 165aa2b

Browse files
committed
Further code reduction
1 parent 6244644 commit 165aa2b

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

Sources/Testing/Attachments/Attachment.swift

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,6 @@ extension Attachment where AttachableValue: ~Copyable {
124124
}
125125
}
126126

127-
@_spi(ForToolsIntegrationOnly)
128-
extension Attachment where AttachableValue == AnyAttachable {
129-
/// Create a type-erased attachment from an instance of ``Attachment``.
130-
///
131-
/// - Parameters:
132-
/// - attachment: The attachment to type-erase.
133-
fileprivate init(_ attachment: Attachment<some Attachable & Sendable & ~Copyable>) {
134-
self.init(
135-
storage: Storage(AnyAttachable(attachment)),
136-
fileSystemPath: attachment.fileSystemPath,
137-
_preferredName: attachment._preferredName,
138-
sourceLocation: attachment.sourceLocation
139-
)
140-
}
141-
}
142-
143127
/// A type-erased wrapper type that represents any attachable value.
144128
///
145129
/// This type is not generally visible to developers. It is used when posting
@@ -276,8 +260,12 @@ extension Attachment where AttachableValue: Sendable & ~Copyable {
276260
/// }
277261
@_documentation(visibility: private)
278262
public static func record(_ attachment: consuming Self, sourceLocation: SourceLocation = #_sourceLocation) {
279-
var attachmentCopy = Attachment<AnyAttachable>(attachment)
280-
attachmentCopy.sourceLocation = sourceLocation
263+
var attachmentCopy = Attachment<AnyAttachable>(
264+
AnyAttachable(copy attachment),
265+
named: attachment._preferredName,
266+
sourceLocation: sourceLocation
267+
)
268+
attachmentCopy.fileSystemPath = attachment.fileSystemPath
281269
Event.post(.valueAttached(attachmentCopy))
282270
}
283271

0 commit comments

Comments
 (0)