@@ -58,6 +58,12 @@ extension ABI {
5858 /// - Warning: Errors are not yet part of the JSON schema.
5959 var _error : EncodedError < V > ?
6060
61+ /// The comment associated with the call to `withKnownIssue()` that
62+ /// generated this issue.
63+ ///
64+ /// - Warning: This field is not yet part of the JSON schema.
65+ var _knownIssueComment : String ?
66+
6167 init ( encoding issue: borrowing Issue , in eventContext: borrowing Event . Context ) {
6268 // >= v0
6369 isKnown = issue. isKnown
@@ -80,6 +86,9 @@ extension ABI {
8086 if let error = issue. error {
8187 _error = EncodedError ( encoding: error, in: eventContext)
8288 }
89+ if let knownIssueContext = issue. knownIssueContext {
90+ _knownIssueComment = knownIssueContext. comment? . rawValue
91+ }
8392 }
8493 }
8594 }
@@ -89,47 +98,3 @@ extension ABI {
8998
9099extension ABI . EncodedIssue : Codable { }
91100extension ABI . EncodedIssue . Severity : Codable { }
92-
93- // MARK: - Converting back to an Issue
94-
95- extension Issue {
96- /// Attempt to reconstruct an instance of ``Issue`` from the given encoded
97- /// event.
98- ///
99- /// - Parameters:
100- /// - event: The event that may contain an encoded issue.
101- ///
102- /// If `event` does not represent an issue, this initializer returns `nil`.
103- init ? < V> ( _ event: ABI . EncodedEvent < V > ) {
104- guard let issue = event. issue else {
105- return nil
106- }
107-
108- // Translate the issue back into a "real" issue and record it
109- // in the parent process. This translation is, of course, lossy
110- // due to the process boundary, but we make a best effort.
111- let comments : [ Comment ] = event. messages. map ( \. text) . map ( Comment . init ( rawValue: ) )
112- let issueKind : Issue . Kind = if let error = issue. _error {
113- . errorCaught( error)
114- } else {
115- // TODO: improve fidelity of issue kind reporting (especially those without associated values)
116- . unconditional
117- }
118- let severity : Issue . Severity = switch issue. severity {
119- case . warning:
120- . warning
121- case nil , . error:
122- . error
123- }
124- let sourceContext = SourceContext (
125- backtrace: nil , // `issue._backtrace` will have the wrong address space.
126- sourceLocation: issue. sourceLocation
127- )
128- self . init ( kind: issueKind, severity: severity, comments: comments, sourceContext: sourceContext)
129- if issue. isKnown {
130- // The known issue comment, if there was one, is already included in
131- // the `comments` array above.
132- knownIssueContext = Issue . KnownIssueContext ( )
133- }
134- }
135- }
0 commit comments