Created
March 31, 2025 06:17
-
-
Save ObuchiYuki/6896c6397f79b6fc9047e5240cbf82a9 to your computer and use it in GitHub Desktop.
This code causes the compiler to enter an infinite loop only in the Release build. このコードはRelease Buildでだけコンパイラの無限ループを引き起こします
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIMenu { | |
private var childrenView: some View { | |
ForEach(self.children, id: \.self) { element in | |
element.swiftUIViewAsElement | |
} | |
} | |
func incompleteConvertionForSwiftUI() -> some View { | |
self.childrenView | |
} | |
@ViewBuilder | |
fileprivate var swiftUIView: some View { | |
if self.options.contains(.displayInline) { | |
Section(self.title) { | |
self.withPreferredElementSize() | |
} | |
} else { | |
Menu(content: { | |
self.withPreferredElementSize() | |
}, label: { | |
if let image = self.image { | |
Label(title: { Text(self.title) }, icon: { Image(uiImage: image) }) | |
} else { | |
Text(self.title) | |
} | |
}) | |
} | |
} | |
@ViewBuilder | |
private func withPreferredElementSize() -> some View { | |
switch self.preferredElementSize { | |
case .small: | |
ControlGroup { self.childrenView }.controlGroupStyle(.compactMenu) | |
case .medium: | |
ControlGroup { self.childrenView }.controlGroupStyle(.menu) | |
case .automatic: | |
self.childrenView | |
case .large: | |
self.childrenView | |
@unknown default: | |
self.childrenView | |
} | |
} | |
} | |
extension UIMenuElement { | |
@ViewBuilder | |
fileprivate var swiftUIViewAsElement: some View { | |
if let menu = self as? UIMenu { | |
menu.swiftUIView | |
} else { | |
EmptyView() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment