OpenSwiftUIProject / OpenSwiftUI

[WIP] Open source implementation of Apple's SwiftUI.
https://swiftpackageindex.com/OpenSwiftUIProject/OpenSwiftUI/main/documentation/openswiftui
MIT License
937 stars 27 forks source link

constructing an object of class type 'Delegate' with a metatype value must use a 'required' initializer #41

Open Kyle-Ye opened 6 months ago

Kyle-Ye commented 6 months ago
class FallbackDelegateBox<Delegate: NSObject>: AnyFallbackDelegateBox {
    var storage: DelegateStorage

    enum DelegateStorage {
        case type(_ type: Delegate.Type)
        case instance(_ delegate: Delegate)
    }

    override var delegate: NSObject? {
        switch storage {
        case let .type(type):
            let delegate = type.init() // error: constructing an object of class type 'Delegate' with a metatype value must use a 'required' initializer
            ...
        }
        #endif
    }
}
Kyle-Ye commented 6 months ago

Tracked upstream via https://github.com/apple/swift/issues/71874