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: < %t/FeatureTest.swiftinterface
612
713// REQUIRES: concurrency
814
915// Ensure that when we emit a Swift interface that makes use of new features,
1016// the uses of those features are guarded by appropriate #if's that allow older
1117// compilers to skip over the uses of newer features.
1218
19+ // Some feature gaurds are retired when the first compiler that supports the
20+ // feature is old enough. The --implicit-check-not arguments to FileCheck above
21+ // verify that those guards no longer pollute the emitted interface.
22+
1323// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
1424// CHECK: @_specialize(exported: true, kind: full, availability: macOS, introduced: 12; where T == Swift.Int)
1525// CHECK: public func specializeWithAvailability<T>(_ t: T)
2030public func specializeWithAvailability< T> ( _ t: T ) {
2131}
2232
23- // CHECK-NOT: #if compiler(>=5.3) && $Actors
2433// CHECK: public actor MyActor
2534// CHECK: @_semantics("defaultActor") nonisolated final public var unownedExecutor: _Concurrency.UnownedSerialExecutor {
2635// CHECK-NEXT: get
@@ -29,16 +38,13 @@ public func specializeWithAvailability<T>(_ t: T) {
2938public actor MyActor {
3039}
3140
32- // CHECK-NOT: #if compiler(>=5.3) && $Actors
3341// CHECK: extension FeatureTest.MyActor
3442public extension MyActor {
35- // CHECK-NOT: $Actors
3643 // CHECK: testFunc
3744 func testFunc( ) async { }
3845 // CHECK: }
3946}
4047
41- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
4248// CHECK: globalAsync
4349public func globalAsync( ) async { }
4450
@@ -50,7 +56,6 @@ public func globalAsync() async { }
5056// CHECK-NEXT: }
5157@_marker public protocol MP2 : MP { }
5258
53- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
5459// CHECK: public protocol MP3 : AnyObject, FeatureTest.MP {
5560// CHECK-NEXT: }
5661public protocol MP3 : AnyObject , MP { }
@@ -63,14 +68,12 @@ extension MP2 {
6368
6469// CHECK: class OldSchool : FeatureTest.MP {
6570public class OldSchool : MP {
66- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
6771 // CHECK: takeClass()
6872 public func takeClass( ) async { }
6973}
7074
7175// CHECK: class OldSchool2 : FeatureTest.MP {
7276public class OldSchool2 : MP {
73- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
7477 // CHECK: takeClass()
7578 public func takeClass( ) async { }
7679}
@@ -110,41 +113,32 @@ public struct IsRP: RP {
110113// CHECK-NEXT: public func acceptsRP
111114public func acceptsRP< T: RP > ( _: T ) { }
112115
113- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
114116// CHECK: extension Swift.Array : FeatureTest.MP where Element : FeatureTest.MP {
115117extension Array : FeatureTest . MP where Element : FeatureTest . MP { }
116118// CHECK: }
117119
118- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
119120// CHECK: extension FeatureTest.OldSchool : Swift.UnsafeSendable {
120121extension OldSchool : UnsafeSendable { }
121122// CHECK-NEXT: }
122123
123124
124- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
125125// CHECK: func runSomethingSomewhere
126126public func runSomethingSomewhere( body: ( ) async -> Void ) { }
127127
128- // CHECK-NOT: #if compiler(>=5.3) && $Sendable
129- // CHECK: func runSomethingConcurrently(body: @Sendable () ->
128+ // CHECK: func runSomethingConcurrently(body: @Sendable () ->
130129public func runSomethingConcurrently( body: @Sendable ( ) -> Void ) { }
131130
132- // CHECK-NOT: #if compiler(>=5.3) && $Actors
133131// CHECK: func stage
134132public func stage( with actor : MyActor ) { }
135133
136- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait && $Sendable && $InheritActorContext
137134// CHECK: func asyncIsh
138135public func asyncIsh( @_inheritActorContext operation: @Sendable @escaping ( ) async -> Void ) { }
139136
140- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
141137// CHECK: #if compiler(>=5.3) && $UnsafeInheritExecutor
142138// CHECK: @_unsafeInheritExecutor public func unsafeInheritExecutor() async
143139@_unsafeInheritExecutor
144140public func unsafeInheritExecutor( ) async { }
145141
146- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
147- // CHECK-NOT: #if $UnsafeInheritExecutor
148142// CHECK: #elseif compiler(>=5.3) && $SpecializeAttributeWithAvailability
149143// CHECK: @_specialize{{.*}}
150144// CHECK: public func multipleSuppressible<T>(value: T) async
0 commit comments