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: < %t/FeatureTest.swiftinterface
6
12
7
13
// REQUIRES: concurrency
8
14
9
15
// Ensure that when we emit a Swift interface that makes use of new features,
10
16
// the uses of those features are guarded by appropriate #if's that allow older
11
17
// compilers to skip over the uses of newer features.
12
18
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
+
13
23
// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
14
24
// CHECK: @_specialize(exported: true, kind: full, availability: macOS, introduced: 12; where T == Swift.Int)
15
25
// CHECK: public func specializeWithAvailability<T>(_ t: T)
20
30
public func specializeWithAvailability< T> ( _ t: T ) {
21
31
}
22
32
23
- // CHECK-NOT: #if compiler(>=5.3) && $Actors
24
33
// CHECK: public actor MyActor
25
34
// CHECK: @_semantics("defaultActor") nonisolated final public var unownedExecutor: _Concurrency.UnownedSerialExecutor {
26
35
// CHECK-NEXT: get
@@ -29,16 +38,13 @@ public func specializeWithAvailability<T>(_ t: T) {
29
38
public actor MyActor {
30
39
}
31
40
32
- // CHECK-NOT: #if compiler(>=5.3) && $Actors
33
41
// CHECK: extension FeatureTest.MyActor
34
42
public extension MyActor {
35
- // CHECK-NOT: $Actors
36
43
// CHECK: testFunc
37
44
func testFunc( ) async { }
38
45
// CHECK: }
39
46
}
40
47
41
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
42
48
// CHECK: globalAsync
43
49
public func globalAsync( ) async { }
44
50
@@ -50,7 +56,6 @@ public func globalAsync() async { }
50
56
// CHECK-NEXT: }
51
57
@_marker public protocol MP2 : MP { }
52
58
53
- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
54
59
// CHECK: public protocol MP3 : AnyObject, FeatureTest.MP {
55
60
// CHECK-NEXT: }
56
61
public protocol MP3 : AnyObject , MP { }
@@ -63,14 +68,12 @@ extension MP2 {
63
68
64
69
// CHECK: class OldSchool : FeatureTest.MP {
65
70
public class OldSchool : MP {
66
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
67
71
// CHECK: takeClass()
68
72
public func takeClass( ) async { }
69
73
}
70
74
71
75
// CHECK: class OldSchool2 : FeatureTest.MP {
72
76
public class OldSchool2 : MP {
73
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
74
77
// CHECK: takeClass()
75
78
public func takeClass( ) async { }
76
79
}
@@ -110,41 +113,32 @@ public struct IsRP: RP {
110
113
// CHECK-NEXT: public func acceptsRP
111
114
public func acceptsRP< T: RP > ( _: T ) { }
112
115
113
- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
114
116
// CHECK: extension Swift.Array : FeatureTest.MP where Element : FeatureTest.MP {
115
117
extension Array : FeatureTest . MP where Element : FeatureTest . MP { }
116
118
// CHECK: }
117
119
118
- // CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
119
120
// CHECK: extension FeatureTest.OldSchool : Swift.UnsafeSendable {
120
121
extension OldSchool : UnsafeSendable { }
121
122
// CHECK-NEXT: }
122
123
123
124
124
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
125
125
// CHECK: func runSomethingSomewhere
126
126
public func runSomethingSomewhere( body: ( ) async -> Void ) { }
127
127
128
- // CHECK-NOT: #if compiler(>=5.3) && $Sendable
129
- // CHECK: func runSomethingConcurrently(body: @Sendable () ->
128
+ // CHECK: func runSomethingConcurrently(body: @Sendable () ->
130
129
public func runSomethingConcurrently( body: @Sendable ( ) -> Void ) { }
131
130
132
- // CHECK-NOT: #if compiler(>=5.3) && $Actors
133
131
// CHECK: func stage
134
132
public func stage( with actor : MyActor ) { }
135
133
136
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait && $Sendable && $InheritActorContext
137
134
// CHECK: func asyncIsh
138
135
public func asyncIsh( @_inheritActorContext operation: @Sendable @escaping ( ) async -> Void ) { }
139
136
140
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
141
137
// CHECK: #if compiler(>=5.3) && $UnsafeInheritExecutor
142
138
// CHECK: @_unsafeInheritExecutor public func unsafeInheritExecutor() async
143
139
@_unsafeInheritExecutor
144
140
public func unsafeInheritExecutor( ) async { }
145
141
146
- // CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
147
- // CHECK-NOT: #if $UnsafeInheritExecutor
148
142
// CHECK: #elseif compiler(>=5.3) && $SpecializeAttributeWithAvailability
149
143
// CHECK: @_specialize{{.*}}
150
144
// CHECK: public func multipleSuppressible<T>(value: T) async
0 commit comments