-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathback-deployed-attr.swift
85 lines (73 loc) · 3.06 KB
/
back-deployed-attr.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-module-interface(%t/Test.swiftinterface) %s \
// RUN: -define-availability "_macOS12_1:macOS 12.1" \
// RUN: -define-availability "_myProject 1.0:macOS 12.1, iOS 15.1"
// RUN: %target-swift-typecheck-module-from-interface(%t/Test.swiftinterface)
// RUN: %FileCheck %s < %t/Test.swiftinterface
// REQUIRES: OS=macosx
public struct TopLevelStruct {
// CHECK: @backDeployed(before: macOS 12.0)
// CHECK: public func backDeployedFunc_SinglePlatform() -> Swift.Int { return 41 }
@backDeployed(before: macOS 12.0)
public func backDeployedFunc_SinglePlatform() -> Int { return 41 }
// CHECK: @backDeployed(before: macOS 12.0, iOS 15.0)
// CHECK: public func backDeployedFunc_MultiPlatform() -> Swift.Int { return 42 }
@backDeployed(before: macOS 12.0, iOS 15.0)
public func backDeployedFunc_MultiPlatform() -> Int { return 42 }
// CHECK: @backDeployed(before: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0)
// CHECK: public func backDeployedFunc_MultiPlatformSeparate() -> Swift.Int { return 43 }
@backDeployed(before: macOS 12.0)
@backDeployed(before: iOS 15.0)
@backDeployed(before: watchOS 8.0)
@backDeployed(before: tvOS 15.0)
public func backDeployedFunc_MultiPlatformSeparate() -> Int { return 43 }
// CHECK: @backDeployed(before: macOS 12.0)
// CHECK: public var backDeployedComputedProperty: Swift.Int {
// CHECK-NEXT: get { 44 }
// CHECK-NEXT: }
@backDeployed(before: macOS 12.0)
public var backDeployedComputedProperty: Int { 44 }
// CHECK: @backDeployed(before: macOS 12.0)
// CHECK: public var backDeployedPropertyWithAccessors: Swift.Int {
// CHECK-NEXT: get { 45 }
// CHECK-NEXT: }
@backDeployed(before: macOS 12.0)
public var backDeployedPropertyWithAccessors: Int {
get { 45 }
}
// CHECK: @backDeployed(before: macOS 12.0)
// CHECK: public subscript(index: Swift.Int) -> Swift.Int {
// CHECK-NEXT: get { 46 }
// CHECK-NEXT: }
@backDeployed(before: macOS 12.0)
public subscript(index: Int) -> Int {
get { 46 }
}
}
// CHECK: @backDeployed(before: iOS 15.0)
// CHECK: public func backDeployedFunc_iOSOnly() -> Swift.Int
// CHECK-NOT: return 99
@backDeployed(before: iOS 15.0)
public func backDeployedFunc_iOSOnly() -> Int { return 99 }
// CHECK: @backDeployed(before: macOS 12.0)
// CHECK: public func backDeployTopLevelFunc_macOS() -> Swift.Int {
// CHECK-NEXT: return 47
// CHECK-NEXT: }
// CHECK-NOT: fatalError()
@backDeployed(before: macOS 12.0)
public func backDeployTopLevelFunc_macOS() -> Int {
#if os(macOS)
return 47
#else
fatalError()
#endif
}
// MARK: - Availability macros
// CHECK: @backDeployed(before: macOS 12.1)
// CHECK: public func backDeployTopLevelFunc_macOS12_1() -> Swift.Int { return 48 }
@backDeployed(before: _macOS12_1)
public func backDeployTopLevelFunc_macOS12_1() -> Int { return 48 }
// CHECK: @backDeployed(before: macOS 12.1, iOS 15.1)
// CHECK: public func backDeployTopLevelFunc_myProject() -> Swift.Int { return 49 }
@backDeployed(before: _myProject 1.0)
public func backDeployTopLevelFunc_myProject() -> Int { return 49 }