@@ -58,9 +58,6 @@ func test0() -> Bool {
58
58
// Check that this cast does not get eliminated, because
59
59
// the compiler does not statically know if this object
60
60
// is NSNumber can be converted into Int.
61
- // CHECK-LABEL: sil [noinline] @_TF17cast_folding_objc35testMayBeBridgedCastFromObjCtoSwiftFPs9AnyObject_Si
62
- // CHECK: unconditional_checked_cast_addr
63
- // CHECK: return
64
61
@inline ( never)
65
62
public func testMayBeBridgedCastFromObjCtoSwift( _ o: AnyObject ) -> Int {
66
63
return o as! Int
@@ -69,9 +66,6 @@ public func testMayBeBridgedCastFromObjCtoSwift(_ o: AnyObject) -> Int {
69
66
// Check that this cast does not get eliminated, because
70
67
// the compiler does not statically know if this object
71
68
// is NSString can be converted into String.
72
- // CHECK-LABEL: sil [noinline] @_TF17cast_folding_objc41testConditionalBridgedCastFromObjCtoSwiftFPs9AnyObject_GSqSS_
73
- // CHECK: unconditional_checked_cast_addr
74
- // CHECK: return
75
69
@inline ( never)
76
70
public func testConditionalBridgedCastFromObjCtoSwift( _ o: AnyObject ) -> String ? {
77
71
return o as? String
@@ -101,174 +95,179 @@ public func testFailingBridgedCastFromSwiftToObjC(_ s: String) -> NSInteger {
101
95
return s as! NSInteger
102
96
}
103
97
104
- // Check that class instances may be cast to potentially-class metatypes.
105
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastNSObjectToAnyClass{{.*}}
106
- // CHECK: unconditional_checked_cast_addr
107
98
@inline ( never)
108
99
public func testCastNSObjectToAnyClass( _ o: NSObject ) -> AnyClass {
109
100
return o as! AnyClass
110
101
}
111
102
112
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastNSObjectToClassObject{{.*}}
113
- // CHECK: unconditional_checked_cast_addr
114
103
@inline ( never)
115
104
public func testCastNSObjectToClassObject( _ o: NSObject ) -> NSObject . Type {
116
105
return o as! NSObject . Type
117
106
}
118
107
119
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastNSObjectToAnyType{{.*}}
120
- // CHECK: unconditional_checked_cast_addr
121
108
@inline ( never)
122
109
public func testCastNSObjectToAnyType( _ o: NSObject ) -> Any . Type {
123
110
return o as! Any . Type
124
111
}
125
112
126
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastNSObjectToEveryType{{.*}}
127
- // CHECK: unconditional_checked_cast_addr
128
113
@inline ( never)
129
114
public func testCastNSObjectToEveryType< T> ( _ o: NSObject ) -> T . Type {
130
115
return o as! T . Type
131
116
}
132
117
133
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastNSObjectToNonClassType
134
- // CHECK: builtin "int_trap"
135
118
@inline ( never)
136
119
public func testCastNSObjectToNonClassType( _ o: NSObject ) -> Int . Type {
137
120
return o as! Int . Type
138
121
}
139
122
140
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyObjectToAnyClass{{.*}}
141
- // CHECK: unconditional_checked_cast_addr
142
123
@inline ( never)
143
124
public func testCastAnyObjectToAnyClass( _ o: AnyObject ) -> AnyClass {
144
125
return o as! AnyClass
145
126
}
146
127
147
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyObjectToClassObject{{.*}}
148
- // CHECK: unconditional_checked_cast_addr
149
128
@inline ( never)
150
129
public func testCastAnyObjectToClassObject( _ o: AnyObject ) -> AnyObject . Type {
151
130
return o as! AnyObject . Type
152
131
}
153
132
154
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyObjectToAnyType{{.*}}
155
- // CHECK: unconditional_checked_cast_addr
156
133
@inline ( never)
157
134
public func testCastAnyObjectToAnyType( _ o: AnyObject ) -> Any . Type {
158
135
return o as! Any . Type
159
136
}
160
137
161
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyObjectToEveryType{{.*}}
162
- // CHECK: unconditional_checked_cast_addr
163
138
@inline ( never)
164
139
public func testCastAnyObjectToEveryType< T> ( _ o: AnyObject ) -> T . Type {
165
140
return o as! T . Type
166
141
}
167
142
168
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyObjectToNonClassType
169
- // CHECK: builtin "int_trap"
170
143
@inline ( never)
171
144
public func testCastAnyObjectToNonClassType( _ o: AnyObject ) -> Int . Type {
172
145
return o as! Int . Type
173
146
}
174
147
175
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToAnyClass{{.*}}
176
- // CHECK: unconditional_checked_cast_addr
177
148
@inline ( never)
178
149
public func testCastAnyToAnyClass( _ o: Any ) -> AnyClass {
179
150
return o as! AnyClass
180
151
}
181
152
182
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToClassObject{{.*}}
183
- // CHECK: unconditional_checked_cast_addr
184
153
@inline ( never)
185
154
public func testCastAnyToClassObject( _ o: Any ) -> AnyObject . Type {
186
155
return o as! AnyObject . Type
187
156
}
188
157
189
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToAnyType{{.*}}
190
- // CHECK: unconditional_checked_cast_addr
191
158
@inline ( never)
192
159
public func testCastAnyToAnyType( _ o: Any ) -> Any . Type {
193
160
return o as! Any . Type
194
161
}
195
162
196
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToEveryType{{.*}}
197
- // CHECK: unconditional_checked_cast_addr
198
163
@inline ( never)
199
164
public func testCastAnyToEveryType< T> ( _ o: Any ) -> T . Type {
200
165
return o as! T . Type
201
166
}
202
167
203
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToNonClassType
204
- // CHECK: unconditional_checked_cast_addr
205
168
@inline ( never)
206
169
public func testCastAnyToNonClassType( _ o: Any ) -> Int . Type {
207
170
return o as! Int . Type
208
171
}
209
172
210
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToAnyClass{{.*}}
211
- // CHECK: unconditional_checked_cast_addr
212
173
@inline ( never)
213
174
public func testCastEveryToAnyClass< T> ( _ o: T ) -> AnyClass {
214
175
return o as! AnyClass
215
176
}
216
177
217
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToClassObject{{.*}}
218
- // CHECK: unconditional_checked_cast_addr
219
178
@inline ( never)
220
179
public func testCastEveryToClassObject< T> ( _ o: T ) -> AnyObject . Type {
221
180
return o as! AnyObject . Type
222
181
}
223
182
224
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToAnyType{{.*}}
225
- // CHECK: unconditional_checked_cast_addr
226
183
@inline ( never)
227
184
public func testCastEveryToAnyType< T> ( _ o: T ) -> Any . Type {
228
185
return o as! Any . Type
229
186
}
230
187
231
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToEveryType{{.*}}
232
- // CHECK: unconditional_checked_cast_addr
233
188
@inline ( never)
234
189
public func testCastEveryToEveryType< T, U> ( _ o: U ) -> T . Type {
235
190
return o as! T . Type
236
191
}
237
192
238
- // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToNonClassType
239
- // CHECK: unconditional_checked_cast_addr
240
193
@inline ( never)
241
194
public func testCastEveryToNonClassType< T> ( _ o: T ) -> Int . Type {
242
195
return o as! Int . Type
243
196
}
244
197
245
198
print ( " test0= \( test0 ( ) ) " )
246
199
200
+
201
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastNSObjectToEveryType{{.*}}
202
+ // CHECK: unconditional_checked_cast_addr
203
+
204
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastNSObjectToNonClassType
205
+ // CHECK: builtin "int_trap"
206
+
207
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyObjectToEveryType{{.*}}
208
+ // CHECK: unconditional_checked_cast_addr
209
+
210
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyObjectToNonClassType
211
+ // CHECK: builtin "int_trap"
212
+
213
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToAnyClass{{.*}}
214
+ // CHECK: unconditional_checked_cast_addr
215
+
216
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToClassObject{{.*}}
217
+ // CHECK: unconditional_checked_cast_addr
218
+
219
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToAnyType{{.*}}
220
+ // CHECK: unconditional_checked_cast_addr
221
+
222
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToEveryType{{.*}}
223
+ // CHECK: unconditional_checked_cast_addr
224
+
225
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastAnyToNonClassType
226
+ // CHECK: unconditional_checked_cast_addr
227
+
228
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToAnyClass{{.*}}
229
+ // CHECK: unconditional_checked_cast_addr
230
+
231
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToClassObject{{.*}}
232
+ // CHECK: unconditional_checked_cast_addr
233
+
234
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToAnyType{{.*}}
235
+ // CHECK: unconditional_checked_cast_addr
236
+
237
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToEveryType{{.*}}
238
+ // CHECK: unconditional_checked_cast_addr
239
+
240
+ // CHECK-LABEL: sil [noinline] @{{.*}}testCastEveryToNonClassType
241
+ // CHECK: unconditional_checked_cast_addr
242
+
243
+
244
+
247
245
// Check that compiler understands that this cast always succeeds.
248
246
// Since it is can be statically proven that NSString is bridgeable to String,
249
247
// _forceBridgeFromObjectiveC from String should be invoked instead of
250
248
// a more general, but less effective swift_bridgeNonVerbatimFromObjectiveC, which
251
249
// also performs conformance checks at runtime.
252
- // CHECK-LABEL: sil [noinline] @_TTSf4g___TF17cast_folding_objc30testBridgedCastFromObjCtoSwiftFCSo8NSStringSS
253
- // CHECK-NOT: {{ cast}}
254
- // CHECK: metatype $@thick String.Type
255
- // CHECK: function_ref @_TTWSSs21_ObjectiveCBridgeable10FoundationZFS_26_forceBridgeFromObjectiveCfTwx15_ObjectiveCType6resultRGSqx__T_
256
- // CHECK: apply
257
- // CHECK: return
258
250
@inline ( never)
259
251
public func testBridgedCastFromObjCtoSwift( _ ns: NSString ) -> String {
260
252
return ns as String
261
253
}
262
254
263
255
// Check that compiler understands that this cast always succeeds
264
- // CHECK-LABEL: sil [noinline] @_TTSf4gs___TF17cast_folding_objc30testBridgedCastFromSwiftToObjCFSSCSo8NSString
265
- // CHECK-NOT: {{ cast}}
266
- // CHECK: function_ref @_TFE10FoundationSS19_bridgeToObjectiveC
267
- // CHECK: apply
268
- // CHECK: return
269
256
@inline ( never)
270
257
public func testBridgedCastFromSwiftToObjC( _ s: String ) -> NSString {
271
258
return s as NSString
272
259
}
273
260
261
+ // CHECK-LABEL: sil [noinline] @_TTSf4g___TF17cast_folding_objc35testMayBeBridgedCastFromObjCtoSwiftFPs9AnyObject_Si
262
+ // CHECK: unconditional_checked_cast_addr
263
+ // CHECK: return
264
+
265
+ // CHECK-LABEL: sil [noinline] @_TTSf4g___TF17cast_folding_objc41testConditionalBridgedCastFromObjCtoSwiftFPs9AnyObject_GSqSS_
266
+ // CHECK: unconditional_checked_cast_addr
267
+ // CHECK: return
274
268
269
+ // CHECK-LABEL: sil [noinline] @_TTSf4gs___TF17cast_folding_objc30testBridgedCastFromSwiftToObjCFSSCSo8NSString
270
+ // CHECK-NOT: {{ cast}}
271
+ // CHECK: function_ref @_TFE10FoundationSS19_bridgeToObjectiveC
272
+ // CHECK: apply
273
+ // CHECK: return
0 commit comments