mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Previously, when creating availability attributes for synthesized declarations we would identify some set of reference declarations that the synthesized declaration should be as-available-as. The availability attributes of the reference declarations would then be merged together to create the attributes for the synthesized declaration. The problem with this approach is that the reference declarations themselves may implicitly inherit availability from their enclosing scopes, so the resulting merged attributes could be incomplete. The fix is to walk though the enclosing scopes of the reference declarations, merging the availability attributes found at each level. Additionally, the merging algorithm that produces inferred availability attributes failed to deal with conflicts between platform specific and platform agnostic availability. Now the merging algorithm notices when platform agnostic availability should take precedence and avoids generating conflicting platform specific attributes. Resolves rdar://106575142
34 lines
575 B
Swift
34 lines
575 B
Swift
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx12 -swift-version 5
|
|
|
|
// REQUIRES: objc_interop
|
|
// REQUIRES: OS=macosx
|
|
|
|
import SwiftUI
|
|
|
|
@available(macOS 12, *)
|
|
struct S {}
|
|
|
|
@available(iOS, unavailable)
|
|
extension S {
|
|
class NestedOtherPlatformUnavailable {
|
|
@Published var x: Int = 0
|
|
@Binding var y: Bool
|
|
|
|
init(y: Binding<Bool>) {
|
|
_y = y
|
|
}
|
|
}
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
extension S {
|
|
class NestedAlwaysUnavailable {
|
|
@Published var x: Int = 0
|
|
@Binding var y: Bool
|
|
|
|
init(y: Binding<Bool>) {
|
|
_y = y
|
|
}
|
|
}
|
|
}
|