Commits

Devin Coughlin committed 1165aca5454
[Sema] Suppress deprecation/availability diagnostics in branches with empty availability We currently emit diagnostics for references to deprecated and potentially unavailable APIs in branches that are dead for the current platform and minimum deployment target. These dead branches can arise when sharing swift source between targets or in playgrounds intended to be run on multiple OS versions. So for example, suppose the developer has the following code targeting OSX 10.9+ and iOS 8.0+: if #available(OSX 10.10, *) { // Use replacement API introduced in OSX 10.10/iOS 8.0 } else { // Use old API deprecated in OSX 10.10/iOS 8.0 } Compiling the above for iOS and with a miniminum deployment of 8.0 will result in a deprecation diagnostic for the use of the API in the else branch even though that branch will never execute. (Note that the branch is not dead on the OSX target because the minimum deployment target is 10.9. For OSX we also won't emit a deprecation warning because the API wasn't deprecated until 10.10. This commit updates availability checking to create refinement contexts with empty OS version ranges for #available() else branches when those branches will definitely not execute. It suppresses deprecation and potential availability diagnostics within those contexts. It does not suppress diagnostics for references to APIs annotated as unconditionally unavailable (i.e., with @available(OSX, unavailable, ...) and friends). rdar://problem/22307360 Swift SVN r31631