From f0d1b7fe722e6eda41db2e56f75529956ffa42fa Mon Sep 17 00:00:00 2001 From: Electric Sidecar Date: Mon, 10 Jun 2024 22:34:26 -0700 Subject: [PATCH] Fix "error: circular reference" in Xcode 16.0 beta (16A5171c). FB13830058 tracks upstream resolution of this, as this seems to be a Swift compiler bug. --- Sources/MarkdownUI/DSL/Inlines/Emphasis.swift | 2 +- .../MarkdownUI/DSL/Inlines/InlineImage.swift | 2 +- .../MarkdownUI/DSL/Inlines/InlineLink.swift | 2 +- .../DSL/Inlines/Strikethrough.swift | 2 +- Sources/MarkdownUI/DSL/Inlines/Strong.swift | 2 +- Sources/MarkdownUI/Parser/InlineNode.swift | 20 +++++++++---------- .../MarkdownUI/Parser/MarkdownParser.swift | 10 +++++----- .../MarkdownUI/Views/Inlines/ImageView.swift | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Sources/MarkdownUI/DSL/Inlines/Emphasis.swift b/Sources/MarkdownUI/DSL/Inlines/Emphasis.swift index 9eb17462..ef3db4b8 100644 --- a/Sources/MarkdownUI/DSL/Inlines/Emphasis.swift +++ b/Sources/MarkdownUI/DSL/Inlines/Emphasis.swift @@ -3,7 +3,7 @@ import Foundation /// An emphasized text in a Markdown content block. public struct Emphasis: InlineContentProtocol { public var _inlineContent: InlineContent { - .init(inlines: [.emphasis(children: self.content.inlines)]) + .init(inlines: [.emphasis(self.content.inlines)]) } private let content: InlineContent diff --git a/Sources/MarkdownUI/DSL/Inlines/InlineImage.swift b/Sources/MarkdownUI/DSL/Inlines/InlineImage.swift index 06824583..f9d2497f 100644 --- a/Sources/MarkdownUI/DSL/Inlines/InlineImage.swift +++ b/Sources/MarkdownUI/DSL/Inlines/InlineImage.swift @@ -26,7 +26,7 @@ import Foundation /// ![](InlineImage) public struct InlineImage: InlineContentProtocol { public var _inlineContent: InlineContent { - .init(inlines: [.image(source: self.source, children: self.content.inlines)]) + .init(inlines: [.image(source: self.source, self.content.inlines)]) } private let source: String diff --git a/Sources/MarkdownUI/DSL/Inlines/InlineLink.swift b/Sources/MarkdownUI/DSL/Inlines/InlineLink.swift index c47d6380..84849567 100644 --- a/Sources/MarkdownUI/DSL/Inlines/InlineLink.swift +++ b/Sources/MarkdownUI/DSL/Inlines/InlineLink.swift @@ -30,7 +30,7 @@ import Foundation /// ``` public struct InlineLink: InlineContentProtocol { public var _inlineContent: InlineContent { - .init(inlines: [.link(destination: self.destination, children: self.content.inlines)]) + .init(inlines: [.link(destination: self.destination, self.content.inlines)]) } private let destination: String diff --git a/Sources/MarkdownUI/DSL/Inlines/Strikethrough.swift b/Sources/MarkdownUI/DSL/Inlines/Strikethrough.swift index 8f728f0e..91da556e 100644 --- a/Sources/MarkdownUI/DSL/Inlines/Strikethrough.swift +++ b/Sources/MarkdownUI/DSL/Inlines/Strikethrough.swift @@ -3,7 +3,7 @@ import Foundation /// A deleted or redacted text in a Markdown content block. public struct Strikethrough: InlineContentProtocol { public var _inlineContent: InlineContent { - .init(inlines: [.strikethrough(children: self.content.inlines)]) + .init(inlines: [.strikethrough(self.content.inlines)]) } private let content: InlineContent diff --git a/Sources/MarkdownUI/DSL/Inlines/Strong.swift b/Sources/MarkdownUI/DSL/Inlines/Strong.swift index 93f39867..8a8a5e6a 100644 --- a/Sources/MarkdownUI/DSL/Inlines/Strong.swift +++ b/Sources/MarkdownUI/DSL/Inlines/Strong.swift @@ -3,7 +3,7 @@ import Foundation /// A strong text in a Markdown content block. public struct Strong: InlineContentProtocol { public var _inlineContent: InlineContent { - .init(inlines: [.strong(children: self.content.inlines)]) + .init(inlines: [.strong(self.content.inlines)]) } private let content: InlineContent diff --git a/Sources/MarkdownUI/Parser/InlineNode.swift b/Sources/MarkdownUI/Parser/InlineNode.swift index 3d01a17f..dd7a3c6f 100644 --- a/Sources/MarkdownUI/Parser/InlineNode.swift +++ b/Sources/MarkdownUI/Parser/InlineNode.swift @@ -6,11 +6,11 @@ enum InlineNode: Hashable { case lineBreak case code(String) case html(String) - case emphasis(children: [InlineNode]) - case strong(children: [InlineNode]) - case strikethrough(children: [InlineNode]) - case link(destination: String, children: [InlineNode]) - case image(source: String, children: [InlineNode]) + case emphasis([InlineNode]) + case strong([InlineNode]) + case strikethrough([InlineNode]) + case link(destination: String, [InlineNode]) + case image(source: String, [InlineNode]) } extension InlineNode { @@ -35,15 +35,15 @@ extension InlineNode { set { switch self { case .emphasis: - self = .emphasis(children: newValue) + self = .emphasis(newValue) case .strong: - self = .strong(children: newValue) + self = .strong(newValue) case .strikethrough: - self = .strikethrough(children: newValue) + self = .strikethrough(newValue) case .link(let destination, _): - self = .link(destination: destination, children: newValue) + self = .link(destination: destination, newValue) case .image(let source, _): - self = .image(source: source, children: newValue) + self = .image(source: source, newValue) default: break } diff --git a/Sources/MarkdownUI/Parser/MarkdownParser.swift b/Sources/MarkdownUI/Parser/MarkdownParser.swift index ff6b6655..6c9d601f 100644 --- a/Sources/MarkdownUI/Parser/MarkdownParser.swift +++ b/Sources/MarkdownUI/Parser/MarkdownParser.swift @@ -134,20 +134,20 @@ extension InlineNode { case .html: self = .html(unsafeNode.literal ?? "") case .emphasis: - self = .emphasis(children: unsafeNode.children.compactMap(InlineNode.init(unsafeNode:))) + self = .emphasis(unsafeNode.children.compactMap(InlineNode.init(unsafeNode:))) case .strong: - self = .strong(children: unsafeNode.children.compactMap(InlineNode.init(unsafeNode:))) + self = .strong(unsafeNode.children.compactMap(InlineNode.init(unsafeNode:))) case .strikethrough: - self = .strikethrough(children: unsafeNode.children.compactMap(InlineNode.init(unsafeNode:))) + self = .strikethrough(unsafeNode.children.compactMap(InlineNode.init(unsafeNode:))) case .link: self = .link( destination: unsafeNode.url ?? "", - children: unsafeNode.children.compactMap(InlineNode.init(unsafeNode:)) + unsafeNode.children.compactMap(InlineNode.init(unsafeNode:)) ) case .image: self = .image( source: unsafeNode.url ?? "", - children: unsafeNode.children.compactMap(InlineNode.init(unsafeNode:)) + unsafeNode.children.compactMap(InlineNode.init(unsafeNode:)) ) default: assertionFailure("Unhandled node type '\(unsafeNode.nodeType)' in InlineNode.") diff --git a/Sources/MarkdownUI/Views/Inlines/ImageView.swift b/Sources/MarkdownUI/Views/Inlines/ImageView.swift index 90f97e0a..3aa8aedf 100644 --- a/Sources/MarkdownUI/Views/Inlines/ImageView.swift +++ b/Sources/MarkdownUI/Views/Inlines/ImageView.swift @@ -32,13 +32,13 @@ struct ImageView: View { content: [ .link( destination: destination, - children: [.image(source: self.data.source, children: [.text(self.data.alt)])] + [.image(source: self.data.source, [.text(self.data.alt)])] ) ] ) } else { return .paragraph( - content: [.image(source: self.data.source, children: [.text(self.data.alt)])] + content: [.image(source: self.data.source, [.text(self.data.alt)])] ) } }