SwiftUI collaboration needed to eliminate compiler hack

Back when #33493 landed, we had to introduce a hack to work around several malformed conformances in the SwiftUI.swiftinterface file. In particular, the implementation of the associated type Body in the conditional conformance of Optional to Gesture is being picked up from an extension with constraints that are not satisfied by the conformance context:

extension Optional : Gesture where Wrapped : Gesture {

    /// The type of value produced by this gesture.
    public typealias Value = Wrapped.Value
}

extension Optional : View where Wrapped : View {

    /// The type of gesture representing the body of `Self`.
    public typealias Body = Never
}

The good news is these conformances can now be corrected in an ABI-compatible way by simply redeclaring the typealias in the appropriate extension. Despite SwiftUI not being an open-source project, I am bringing this up in hope of reaching out to and encouraging the SwiftUI folks to fix these issues so that we can subsequently get rid of this unsightly hack and secure ourselves from actually having to keep it behind a language mode.

6 Likes

Hack removed in apple/swift/#59795 :tada:

8 Likes