Files
swift-mirror/validation-test/Sema/SwiftUI/rdar106575142.swift
Allan Shortlidge 4058ad1421 AST: Improved inferred availability accuracy.
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
2023-03-13 18:27:03 -07:00

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
}
}
}