22
33// RUN: %target-swift-emit-module-interface(%t/FeatureTest.swiftinterface) %s -module-name FeatureTest -disable-availability-checking
44// 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
615
716// REQUIRES: concurrency
817
918// Ensure that when we emit a Swift interface that makes use of new features,
1019// the uses of those features are guarded by appropriate #if's that allow older
1120// compilers to skip over the uses of newer features.
1221
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+
1326// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
1427// CHECK: @_specialize(exported: true, kind: full, availability: macOS, introduced: 12; where T == Swift.Int)
1528// CHECK: public func specializeWithAvailability<T>(_ t: T)
2033public func specializeWithAvailability< T> ( _ t: T ) {
2134}
2235
23- // CHECK-NOT: #if compiler(>=5.3) && $Actors
2436// CHECK: public actor MyActor
2537// CHECK: @_semantics("defaultActor") nonisolated final public var unownedExecutor: _Concurrency.UnownedSerialExecutor {
2638// CHECK-NEXT: get
@@ -29,16 +41,13 @@ public func specializeWithAvailability<T>(_ t: T) {
2941public actor MyActor {
3042}
3143
32- // CHECK-NOT: #if compiler(>=5.3) && $Actors
3344// CHECK: extension FeatureTest.MyActor
3445public extension MyActor {
35- // CHECK-NOT: $Actors
3646 // CHECK: testFunc
3747 func testFunc( ) async { }
3848 // CHECK: }
3949}
4050
41- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
4251// CHECK: globalAsync
4352public func globalAsync( ) async { }
4453
@@ -50,7 +59,6 @@ public func globalAsync() async { }
5059// CHECK-NEXT: }
5160@_marker public protocol MP2 : MP { }
5261
53- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
5462// CHECK: public protocol MP3 : AnyObject, FeatureTest.MP {
5563// CHECK-NEXT: }
5664public protocol MP3 : AnyObject , MP { }
@@ -63,14 +71,12 @@ extension MP2 {
6371
6472// CHECK: class OldSchool : FeatureTest.MP {
6573public class OldSchool : MP {
66- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
6774 // CHECK: takeClass()
6875 public func takeClass( ) async { }
6976}
7077
7178// CHECK: class OldSchool2 : FeatureTest.MP {
7279public class OldSchool2 : MP {
73- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
7480 // CHECK: takeClass()
7581 public func takeClass( ) async { }
7682}
@@ -110,62 +116,44 @@ public struct IsRP: RP {
110116// CHECK-NEXT: public func acceptsRP
111117public func acceptsRP< T: RP > ( _: T ) { }
112118
113- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
114119// CHECK: extension Swift.Array : FeatureTest.MP where Element : FeatureTest.MP {
115120extension Array : FeatureTest . MP where Element : FeatureTest . MP { }
116121// CHECK: }
117122
118- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
119123// CHECK: extension FeatureTest.OldSchool : Swift.UnsafeSendable {
120124extension OldSchool : UnsafeSendable { }
121125// CHECK-NEXT: }
122126
123127
124- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
125128// CHECK: func runSomethingSomewhere
126129public func runSomethingSomewhere( body: ( ) async -> Void ) { }
127130
128- // CHECK-NOT: #if compiler(>=5.3) && $Sendable
129- // CHECK: func runSomethingConcurrently(body: @Sendable () ->
131+ // CHECK: func runSomethingConcurrently(body: @Sendable () ->
130132public func runSomethingConcurrently( body: @Sendable ( ) -> Void ) { }
131133
132- // CHECK-NOT: #if compiler(>=5.3) && $Actors
133134// CHECK: func stage
134135public func stage( with actor : MyActor ) { }
135136
136- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait && $Sendable && $InheritActorContext
137137// CHECK: func asyncIsh
138138public func asyncIsh( @_inheritActorContext operation: @Sendable @escaping ( ) async -> Void ) { }
139139
140- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
141- // CHECK: #if compiler(>=5.3) && $UnsafeInheritExecutor
142140// CHECK: @_unsafeInheritExecutor public func unsafeInheritExecutor() async
143141@_unsafeInheritExecutor
144142public func unsafeInheritExecutor( ) async { }
145143
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
149145// CHECK: @_specialize{{.*}}
150- // CHECK: public func multipleSuppressible <T>(value: T) async
146+ // CHECK: public func unsafeInheritExecutorAndSpecialize <T>(value: T) async
151147@_unsafeInheritExecutor
152148@_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 { }
154150
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()
160152@_unavailableFromAsync ( message: " Test " )
161153public func unavailableFromAsyncFunc( ) { }
162154
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")
167156// CHECK-NEXT: public func noAsyncFunc()
168- // CHECK-NEXT: #endif
169157@available ( * , noasync, message: " Test " )
170158public func noAsyncFunc( ) { }
171159
0 commit comments