You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sema: When computing potential unavailability of a decl, first check whether the decl is explicitly unavailable and the context is also unavailable. If those conditions are met, treat the decl as if it were always available since unavailable code is allowed to reference unavailable decls.
Previously, `TypeChecker::checkDeclarationAvailability()` would behave this way for most explicitly unavailable decls by _accident_. An explicitly unavailable decl has no introduction version, and the existing logic therefore would fail to find a lower bound on the availability of the decl. The edge case that exposed the fragility of this logic was an unavailable extension containing a member with it's own explicit availability. The unavailability of the extension ought to trump the availability of the member, but the existing logic couldn't detect that.
The compiler also ought to diagnose the conflicting availability annotations but I'd like to address that separately.
Resolves rdar://92551870
funcWithMultipleShortFormAnnotationsForTheSamePlatform() // expected-error {{'funcWithMultipleShortFormAnnotationsForTheSamePlatform()' is only available in macOS 10.53 or newer}}
1656
1652
// expected-note@-1 {{add 'if #available' version check}}
1653
+
}
1654
+
1655
+
// Unavailability takes precedence over availability and is inherited
1656
+
1657
+
@available(OSX 10.9,*)
1658
+
@available(OSX, unavailable)
1659
+
func unavailableWins(){}
1660
+
// expected-note@-1 {{'unavailableWins()' has been explicitly marked unavailable here}}
1661
+
1662
+
structHasUnavailableExtension{
1663
+
@available(OSX, unavailable)
1664
+
publicfunc directlyUnavailable(){}
1665
+
// expected-note@-1 {{'directlyUnavailable()' has been explicitly marked unavailable here}}
1666
+
}
1667
+
1668
+
@available(OSX, unavailable)
1669
+
extensionHasUnavailableExtension{
1670
+
publicfunc inheritsUnavailable(){}
1671
+
// expected-note@-1 {{'inheritsUnavailable()' has been explicitly marked unavailable here}}
1672
+
1673
+
@available(OSX 10.9,*)
1674
+
publicfunc moreAvailableButStillUnavailable(){}
1675
+
// expected-note@-1 {{'moreAvailableButStillUnavailable()' has been explicitly marked unavailable here}}
osx_more_available_but_still_unavailable_call_osx() // OK
135
+
}
136
+
}
137
+
138
+
func takesOuter(_ o:Outer){
139
+
_ =Outer.outer_osx_init_osx // expected-error {{'outer_osx_init_osx' is unavailable in macOS}}
140
+
o.osx_call_osx() // expected-error {{'osx_call_osx()' is unavailable in macOS}}
141
+
o.osx_more_available_but_still_unavailable_call_osx() // expected-error {{'osx_more_available_but_still_unavailable_call_osx()' is unavailable in macOS}}
0 commit comments