I don’t think this quite captures #available
—the symbol in question is available at runtime compile time (the compiler must know how to emit code that calls it), but the compiler knows that it is only conditionally available at runtime.
IOW, #available
doesn’t support introspection into “can this symbol be looked up?” Rather, you must be compiling against an SDK for which lookup succeeds, but with an availability annotation explaining the availability conditions. In cases where you’re using a bunch of os
directives to winnow down to just the platforms which define some symbol, I do see some value in allowing users to express that semantic intent more directly.
That said, I agree with this intuition:
And I agree that in such a case hasSymbol
becomes a bit messy. One way to resolve this: once we have a fully-qualified name syntax for unambiguously referring to a specific declaration even in the face of shadowing between modules, we could require that the argument to hasSymbol
be a fully-qualified name.