2
2
3
3
// RUN: %target-swift-emit-module-interface(%t/FeatureTest.swiftinterface) %s -module-name FeatureTest -disable-availability-checking
4
4
// RUN: %target-swift-typecheck-module-from-interface(%t/FeatureTest.swiftinterface) -module-name FeatureTest -disable-availability-checking
5
- // RUN: %FileCheck %s < %t/FeatureTest.swiftinterface
5
+ // RUN: %FileCheck %s \
6
+ // RUN: --implicit-check-not "\$AsyncAwait" \
7
+ // RUN: --implicit-check-not "\$Actors" \
8
+ // RUN: --implicit-check-not "\$MarkerProtocol" \
9
+ // RUN: --implicit-check-not "\$Sendable" \
10
+ // RUN: --implicit-check-not "\$InheritActorContext" \
11
+ // RUN: --implicit-check-not "\$UnsafeInheritExecutor" \
12
+ // RUN: --implicit-check-not "\$NoAsyncAvailability" \
13
+ // RUN: --implicit-check-not "\$UnavailableFromAsync" \
14
+ // RUN: < %t/FeatureTest.swiftinterface
6
15
7
16
// REQUIRES: concurrency
8
17
9
18
// Ensure that when we emit a Swift interface that makes use of new features,
10
19
// the uses of those features are guarded by appropriate #if's that allow older
11
20
// compilers to skip over the uses of newer features.
12
21
22
+ // Some feature gaurds are retired when the first compiler that supports the
23
+ // feature is old enough. The --implicit-check-not arguments to FileCheck above
24
+ // verify that those guards no longer pollute the emitted interface.
25
+
13
26
// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
14
27
// CHECK: @_specialize(exported: true, kind: full, availability: macOS, introduced: 12; where T == Swift.Int)
15
28
// CHECK: public func specializeWithAvailability<T>(_ t: T)
20
33
public func specializeWithAvailability< T> ( _ t: T ) {
21
34
}
22
35
23
- // CHECK-NOT: #if compiler(>=5.3) && $Actors
24
36
// CHECK: public actor MyActor
25
37
// CHECK: @_semantics("defaultActor") nonisolated final public var unownedExecutor: _Concurrency.UnownedSerialExecutor {
26
38
// CHECK-NEXT: get
@@ -29,16 +41,13 @@ public func specializeWithAvailability<T>(_ t: T) {
29
41
public actor MyActor {
30
42
}
31
43
32
- // CHECK-NOT: #if compiler(>=5.3) && $Actors
33
44
// CHECK: extension FeatureTest.MyActor
34
45
public extension MyActor {
35
- // CHECK-NOT: $Actors
36
46
// CHECK: testFunc
37
47
func testFunc( ) async { }
38
48
// CHECK: }
39
49
}
40
50
41
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
42
51
// CHECK: globalAsync
43
52
public func globalAsync( ) async { }
44
53
@@ -50,7 +59,6 @@ public func globalAsync() async { }
50
59
// CHECK-NEXT: }
51
60
@_marker public protocol MP2 : MP { }
52
61
53
- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
54
62
// CHECK: public protocol MP3 : AnyObject, FeatureTest.MP {
55
63
// CHECK-NEXT: }
56
64
public protocol MP3 : AnyObject , MP { }
@@ -63,14 +71,12 @@ extension MP2 {
63
71
64
72
// CHECK: class OldSchool : FeatureTest.MP {
65
73
public class OldSchool : MP {
66
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
67
74
// CHECK: takeClass()
68
75
public func takeClass( ) async { }
69
76
}
70
77
71
78
// CHECK: class OldSchool2 : FeatureTest.MP {
72
79
public class OldSchool2 : MP {
73
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
74
80
// CHECK: takeClass()
75
81
public func takeClass( ) async { }
76
82
}
@@ -110,62 +116,44 @@ public struct IsRP: RP {
110
116
// CHECK-NEXT: public func acceptsRP
111
117
public func acceptsRP< T: RP > ( _: T ) { }
112
118
113
- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
114
119
// CHECK: extension Swift.Array : FeatureTest.MP where Element : FeatureTest.MP {
115
120
extension Array : FeatureTest . MP where Element : FeatureTest . MP { }
116
121
// CHECK: }
117
122
118
- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
119
123
// CHECK: extension FeatureTest.OldSchool : Swift.UnsafeSendable {
120
124
extension OldSchool : UnsafeSendable { }
121
125
// CHECK-NEXT: }
122
126
123
127
124
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
125
128
// CHECK: func runSomethingSomewhere
126
129
public func runSomethingSomewhere( body: ( ) async -> Void ) { }
127
130
128
- // CHECK-NOT: #if compiler(>=5.3) && $Sendable
129
- // CHECK: func runSomethingConcurrently(body: @Sendable () ->
131
+ // CHECK: func runSomethingConcurrently(body: @Sendable () ->
130
132
public func runSomethingConcurrently( body: @Sendable ( ) -> Void ) { }
131
133
132
- // CHECK-NOT: #if compiler(>=5.3) && $Actors
133
134
// CHECK: func stage
134
135
public func stage( with actor : MyActor ) { }
135
136
136
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait && $Sendable && $InheritActorContext
137
137
// CHECK: func asyncIsh
138
138
public func asyncIsh( @_inheritActorContext operation: @Sendable @escaping ( ) async -> Void ) { }
139
139
140
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
141
- // CHECK: #if compiler(>=5.3) && $UnsafeInheritExecutor
142
140
// CHECK: @_unsafeInheritExecutor public func unsafeInheritExecutor() async
143
141
@_unsafeInheritExecutor
144
142
public func unsafeInheritExecutor( ) async { }
145
143
146
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
147
- // CHECK-NOT: #if $UnsafeInheritExecutor
148
- // CHECK: #elseif compiler(>=5.3) && $SpecializeAttributeWithAvailability
144
+ // CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
149
145
// CHECK: @_specialize{{.*}}
150
- // CHECK: public func multipleSuppressible <T>(value: T) async
146
+ // CHECK: public func unsafeInheritExecutorAndSpecialize <T>(value: T) async
151
147
@_unsafeInheritExecutor
152
148
@_specialize ( exported: true , availability: SwiftStdlib 5.1 , * ; where T == Int)
153
- public func multipleSuppressible < T> ( value: T ) async { }
149
+ public func unsafeInheritExecutorAndSpecialize < T> ( value: T ) async { }
154
150
155
- // CHECK: #if compiler(>=5.3) && $UnavailableFromAsync
156
- // CHECK-NEXT: @_unavailableFromAsync(message: "Test") public func unavailableFromAsyncFunc()
157
- // CHECK-NEXT: #else
158
- // CHECK-NEXT: public func unavailableFromAsyncFunc()
159
- // CHECK-NEXT: #endif
151
+ // CHECK: @_unavailableFromAsync(message: "Test") public func unavailableFromAsyncFunc()
160
152
@_unavailableFromAsync ( message: " Test " )
161
153
public func unavailableFromAsyncFunc( ) { }
162
154
163
- // CHECK: #if compiler(>=5.3) && $NoAsyncAvailability
164
- // CHECK-NEXT: @available(*, noasync, message: "Test")
165
- // CHECK-NEXT: public func noAsyncFunc()
166
- // CHECK-NEXT: #else
155
+ // CHECK: @available(*, noasync, message: "Test")
167
156
// CHECK-NEXT: public func noAsyncFunc()
168
- // CHECK-NEXT: #endif
169
157
@available ( * , noasync, message: " Test " )
170
158
public func noAsyncFunc( ) { }
171
159
0 commit comments