Skip to content

Commit 4f021a0

Browse files
committed
Tests: Verify that public properties of public types may be annotated with @available for releases up to the current deployment target of the library, even with -target-min-inlining-version min specified.
Resolves rdar://91174092
1 parent 19ebc9b commit 4f021a0

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

test/Sema/availability_stored.swift

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@
33
// Code should type check with a new enough deployment target:
44
// RUN: %target-swift-frontend -typecheck %s -target %target-cpu-apple-macos50
55

6+
// Code should also type check when the library client deployment target is
7+
// lowered via -target-min-inlining-version.
8+
// RUN: %target-swift-frontend -typecheck %s -target %target-cpu-apple-macos50 -enable-library-evolution -target-min-inlining-version min
9+
610
// REQUIRES: OS=macosx
711

812
@available(macOS 50, *)
9-
struct NewStruct {}
13+
public struct NewStruct {}
1014

1115
@available(macOS 50, *)
1216
@propertyWrapper
13-
struct NewPropertyWrapper<Value> {
14-
var wrappedValue: Value
17+
public struct NewPropertyWrapper<Value> {
18+
public var wrappedValue: Value
19+
20+
public init(wrappedValue: Value) {
21+
self.wrappedValue = wrappedValue
22+
}
1523
}
1624

1725
@available(macOS 50, *)
@@ -59,6 +67,21 @@ struct BadReferenceStruct2 {
5967
lazy var z: Int = 42
6068
}
6169

70+
@available(macOS 40, *)
71+
public struct PublicStruct {
72+
// expected-error@+1 {{stored properties cannot be marked potentially unavailable with '@available'}}
73+
@available(macOS 50, *)
74+
public var x: NewStruct
75+
76+
// expected-error@+1 {{stored properties cannot be marked potentially unavailable with '@available'}}
77+
@available(macOS 50, *)
78+
@NewPropertyWrapper public var y: Int
79+
80+
// expected-error@+1 {{stored properties cannot be marked potentially unavailable with '@available'}}
81+
@available(macOS 50, *)
82+
public lazy var z: Int = 42
83+
}
84+
6285
// The same behavior should hold for enum elements with payloads.
6386
@available(macOS 50, *)
6487
enum GoodReferenceEnum {
@@ -84,3 +107,10 @@ enum BadReferenceEnum2 {
84107
@available(macOS 50, *)
85108
case x(NewStruct)
86109
}
110+
111+
@available(macOS 40, *)
112+
public enum PublicReferenceEnum {
113+
// expected-error@+1 {{enum cases with associated values cannot be marked potentially unavailable with '@available'}}
114+
@available(macOS 50, *)
115+
case x(NewStruct)
116+
}

0 commit comments

Comments
 (0)