tristanlabelle / swift-winrt

A Swift Projection for WinRT APIs
MIT License
20 stars 2 forks source link

Migrate to `_`-suffixed `fatalError`'ing properties #372

Closed tristanlabelle closed 3 weeks ago

tristanlabelle commented 3 weeks ago

To more clearly call out when giving up on error handling.

For get/set properties:

The first two are not ambiguous even if the property type is a closure:


class Foo<PropertyType> {
    var property: PropertyType {
        get throws { fatalError() }
    }

    func property(_ value: PropertyType) throws { fatalError() }

    var property_: PropertyType {
        get { fatalError() }
        set { fatalError() }
    }
}

var fooOfInt = Foo<Int>()
_ = try fooOfInt.property
try fooOfInt.property(fooOfInt.property)
fooOfInt.property_ = 42

typealias Callable = () -> Void

var fooOfCallable = Foo<Callable>()
_ = try fooOfCallable.property
try fooOfCallable.property()
try fooOfCallable.property {}
try fooOfCallable.property(fooOfCallable.property)
fooOfCallable.property_ = {}

typealias Func = (Int) -> Void

var fooOfFunc = Foo<Func>()
_ = try fooOfFunc.property
try fooOfFunc.property(42)
try fooOfFunc.property { _ in }
try fooOfFunc.property(fooOfFunc.property)
fooOfFunc.property_ = { _ in }