Using an extension of @Chris_Lattner3 's proposal for dynamicCallable
SE-0216: User-defined dynamically callable types - #68 by dan-zheng (current proposal doesn't handles static
or init
), you could make Never
conform to all types. For all static
and init
functions it dispatches to the dynamicallyCallStaticMethod
method that throws a fatal error. EG:
@dynamicCallable
struct Never {
// Catches all `static` and `init` calls.
@discardableResult
func dynamicallyCallStaticMethod(withName: String, withArguments: [Any]) -> Never {
fatalError("`static` function or `init` called on `Never`!")
}
}