Skip to content

Commit 2d7dc2f

Browse files
committed
Update SILGen tests for id-as-Any.
1 parent d2e1c4a commit 2d7dc2f

9 files changed

+65
-80
lines changed

test/SILGen/collection_downcast.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func testDictionaryDowncastConditional(_ dict: Dictionary<NSObject, AnyObject>)
136136
// CHECK: bb0([[DICT:%[0-9]+]] : $Dictionary<NSObject, AnyObject>)
137137
func testDictionaryDowncastBridgedVConditional(_ dict: Dictionary<NSObject, AnyObject>)
138138
-> Dictionary<BridgedObjC, BridgedSwift>? {
139-
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs42_dictionaryBridgeFromObjectiveCConditional
139+
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs30_dictionaryDownCastConditional
140140
// CHECK-NEXT: apply [[BRIDGE_FN]]<NSObject, AnyObject, BridgedObjC, BridgedSwift>([[DICT]]) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>{{.*}} // user: %6
141141
return dict as? Dictionary<BridgedObjC, BridgedSwift>
142142
}
@@ -145,7 +145,7 @@ func testDictionaryDowncastBridgedVConditional(_ dict: Dictionary<NSObject, AnyO
145145
// CHECK: bb0([[DICT:%[0-9]+]] : $Dictionary<NSObject, AnyObject>)
146146
func testDictionaryDowncastBridgedKConditional(_ dict: Dictionary<NSObject, AnyObject>)
147147
-> Dictionary<BridgedSwift, BridgedObjC>? {
148-
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs42_dictionaryBridgeFromObjectiveCConditional
148+
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs30_dictionaryDownCastConditional
149149
// CHECK-NEXT: apply [[BRIDGE_FN]]<NSObject, AnyObject, BridgedSwift, BridgedObjC>([[DICT]]) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
150150
return dict as? Dictionary<BridgedSwift, BridgedObjC>
151151
}
@@ -154,7 +154,7 @@ func testDictionaryDowncastBridgedKConditional(_ dict: Dictionary<NSObject, AnyO
154154
// CHECK: bb0([[DICT:%[0-9]+]] : $Dictionary<NSObject, AnyObject>)
155155
func testDictionaryDowncastBridgedKV(_ dict: Dictionary<NSObject, AnyObject>)
156156
-> Dictionary<BridgedSwift, BridgedSwift> {
157-
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs31_dictionaryBridgeFromObjectiveC
157+
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs19_dictionaryDownCast
158158
// CHECK-NEXT: apply [[BRIDGE_FN]]<NSObject, AnyObject, BridgedSwift, BridgedSwift>([[DICT]]) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned Dictionary<τ_0_2, τ_0_3>
159159
return dict as! Dictionary<BridgedSwift, BridgedSwift>
160160
}
@@ -163,7 +163,7 @@ func testDictionaryDowncastBridgedKV(_ dict: Dictionary<NSObject, AnyObject>)
163163
// CHECK: bb0([[DICT:%[0-9]+]] : $Dictionary<NSObject, AnyObject>)
164164
func testDictionaryDowncastBridgedKVConditional(_ dict: Dictionary<NSObject, AnyObject>)
165165
-> Dictionary<BridgedSwift, BridgedSwift>? {
166-
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs42_dictionaryBridgeFromObjectiveCConditional
166+
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs30_dictionaryDownCastConditional
167167
// CHECK-NEXT: apply [[BRIDGE_FN]]<NSObject, AnyObject, BridgedSwift, BridgedSwift>([[DICT]]) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
168168
return dict as? Dictionary<BridgedSwift, BridgedSwift>
169169
}
@@ -198,7 +198,7 @@ func testSetDowncastConditional(_ dict: Set<NSObject>)
198198
// CHECK: bb0([[SET:%[0-9]+]] : $Set<NSObject>)
199199
func testSetDowncastBridged(_ dict: Set<NSObject>)
200200
-> Set<BridgedSwift> {
201-
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFs24_setBridgeFromObjectiveC
201+
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFs12_setDownCast
202202
// CHECK-NEXT: apply [[DOWNCAST_FN]]<NSObject, BridgedSwift>([[SET]]) : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@owned Set<τ_0_0>) -> @owned Set<τ_0_1>
203203
return dict as! Set<BridgedSwift>
204204
}
@@ -208,6 +208,6 @@ func testSetDowncastBridged(_ dict: Set<NSObject>)
208208
func testSetDowncastBridgedConditional(_ dict: Set<NSObject>)
209209
-> Set<BridgedSwift>? {
210210
return dict as? Set<BridgedSwift>
211-
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFs35_setBridgeFromObjectiveCConditional
211+
// CHECK: [[DOWNCAST_FN:%[0-9]+]] = function_ref @_TFs23_setDownCastConditional
212212
// CHECK: apply [[DOWNCAST_FN]]<NSObject, BridgedSwift>([[SET]]) : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@owned Set<τ_0_0>) -> @owned Optional<Set<τ_0_1>>
213213
}

test/SILGen/collection_upcast.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func testArrayUpcast(_ array: [BridgedObjC]) {
5858
func testArrayUpcastBridged(_ array: [BridgedSwift]) {
5959
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs15_arrayForceCast{{.*}} : $@convention(thin) <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
6060
// CHECK-NEXT: apply [[BRIDGE_FN]]<BridgedSwift, AnyObject>([[ARRAY]]) : $@convention(thin) <τ_0_0, τ_0_1> (@owned Array<τ_0_0>) -> @owned Array<τ_0_1>
61-
let anyObjectArr: [AnyObject] = array
61+
let anyObjectArr = array as [AnyObject]
6262
}
6363

6464
// CHECK-LABEL: sil hidden @_TF17collection_upcast20testDictionaryUpcast
@@ -72,9 +72,9 @@ func testDictionaryUpcast(_ dict: Dictionary<BridgedObjC, BridgedObjC>) {
7272
// CHECK-LABEL: sil hidden @_TF17collection_upcast27testDictionaryUpcastBridged
7373
// CHECK: bb0([[DICT:%[0-9]+]] : $Dictionary<BridgedSwift, BridgedSwift>):
7474
func testDictionaryUpcastBridged(_ dict: Dictionary<BridgedSwift, BridgedSwift>) {
75-
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs29_dictionaryBridgeToObjectiveC{{.*}} : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned Dictionary<τ_0_2, τ_0_3>
75+
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs17_dictionaryUpCast
7676
// CHECK-NEXT: apply [[BRIDGE_FN]]<BridgedSwift, BridgedSwift, NSObject, AnyObject>([[DICT]]) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned Dictionary<τ_0_2, τ_0_3>
77-
let anyObjectDict: Dictionary<NSObject, AnyObject> = dict
77+
let anyObjectDict = dict as Dictionary<NSObject, AnyObject>
7878
}
7979

8080
// CHECK-LABEL: sil hidden @_TF17collection_upcast13testSetUpcast
@@ -87,8 +87,8 @@ func testSetUpcast(_ dict: Set<BridgedObjC>) {
8787

8888
// CHECK-LABEL: sil hidden @_TF17collection_upcast20testSetUpcastBridged
8989
// CHECK: bb0(%0 : $Set<BridgedSwift>):
90-
func testSetUpcastBridged(_ dict: Set<BridgedSwift>) {
91-
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs22_setBridgeToObjectiveC{{.*}} : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@owned Set<τ_0_0>) -> @owned Set<τ_0_1>
90+
func testSetUpcastBridged(_ set: Set<BridgedSwift>) {
91+
// CHECK: [[BRIDGE_FN:%[0-9]+]] = function_ref @_TFs10_setUpCast
9292
// CHECK: apply [[BRIDGE_FN]]<BridgedSwift, NSObject>([[SET]]) : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@owned Set<τ_0_0>) -> @owned Set<τ_0_1>
93-
let anyObjectSet: Set<NSObject> = dict
93+
let anyObjectSet = set as Set<NSObject>
9494
}

test/SILGen/dynamic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func foreignMethodDispatch() {
302302
// CHECK: class_method [volatile] {{%.*}} : $Gizmo, #Gizmo.count!setter.1.foreign
303303
g.count = x
304304
// CHECK: class_method [volatile] {{%.*}} : $Guisemeau, #Guisemeau.subscript!getter.1.foreign
305-
let y: AnyObject! = g[0]
305+
let y: Any! = g[0]
306306
// CHECK: class_method [volatile] {{%.*}} : $Guisemeau, #Guisemeau.subscript!setter.1.foreign
307307
g[0] = y
308308
// CHECK: class_method [volatile] {{%.*}} : $NSObject, #NSObject.description!getter.1.foreign

test/SILGen/external_definitions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ hasNoPrototype()
2525
// CHECK: apply [[NOPROTO]]()
2626

2727
// -- Constructors for imported Ansible
28-
// CHECK-LABEL: sil shared @_TFCSo7AnsibleC{{.*}} : $@convention(method) (@owned ImplicitlyUnwrappedOptional<AnyObject>, @thick Ansible.Type) -> @owned ImplicitlyUnwrappedOptional<Ansible>
28+
// CHECK-LABEL: sil shared @_TFCSo7AnsibleC{{.*}} : $@convention(method) (@in ImplicitlyUnwrappedOptional<Any>, @thick Ansible.Type) -> @owned ImplicitlyUnwrappedOptional<Ansible>
2929

3030

3131
// -- Constructors for imported NSObject

test/SILGen/foreign_errors.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ func testArgs() throws {
146146
try ErrorProne.consume(nil)
147147
}
148148
// CHECK: sil hidden @_TF14foreign_errors8testArgsFzT_T_ : $@convention(thin) () -> @error Error
149-
// CHECK: class_method [volatile] %0 : $@thick ErrorProne.Type, #ErrorProne.consume!1.foreign : (ErrorProne.Type) -> (AnyObject!) throws -> () , $@convention(objc_method) (ImplicitlyUnwrappedOptional<AnyObject>, ImplicitlyUnwrappedOptional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, @objc_metatype ErrorProne.Type) -> Bool
149+
// CHECK: class_method [volatile] %0 : $@thick ErrorProne.Type, #ErrorProne.consume!1.foreign : (ErrorProne.Type) -> (Any!) throws -> () , $@convention(objc_method) (ImplicitlyUnwrappedOptional<AnyObject>, ImplicitlyUnwrappedOptional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, @objc_metatype ErrorProne.Type) -> Bool
150150

151151
func testBridgedResult() throws {
152152
let array = try ErrorProne.collection(withCount: 0)
153153
}
154154
// CHECK: sil hidden @_TF14foreign_errors17testBridgedResultFzT_T_ : $@convention(thin) () -> @error Error {
155-
// CHECK: class_method [volatile] %0 : $@thick ErrorProne.Type, #ErrorProne.collection!1.foreign : (ErrorProne.Type) -> (withCount: Int) throws -> [AnyObject] , $@convention(objc_method) (Int, ImplicitlyUnwrappedOptional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, @objc_metatype ErrorProne.Type) -> @autoreleased Optional<NSArray>
155+
// CHECK: class_method [volatile] %0 : $@thick ErrorProne.Type, #ErrorProne.collection!1.foreign : (ErrorProne.Type) -> (withCount: Int) throws -> [Any] , $@convention(objc_method) (Int, ImplicitlyUnwrappedOptional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, @objc_metatype ErrorProne.Type) -> @autoreleased Optional<NSArray>
156156

157157
// rdar://20861374
158158
// Clear out the self box before delegating.
@@ -167,7 +167,7 @@ class VeryErrorProne : ErrorProne {
167167
// CHECK: [[MARKED_BOX:%.*]] = mark_uninitialized [derivedself] [[PB]]
168168
// CHECK: [[T0:%.*]] = load [[MARKED_BOX]]
169169
// CHECK-NEXT: [[T1:%.*]] = upcast [[T0]] : $VeryErrorProne to $ErrorProne
170-
// CHECK-NEXT: [[T2:%.*]] = super_method [volatile] [[T0]] : $VeryErrorProne, #ErrorProne.init!initializer.1.foreign : (ErrorProne.Type) -> (one: AnyObject?) throws -> ErrorProne , $@convention(objc_method) (Optional<AnyObject>, ImplicitlyUnwrappedOptional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, @owned ErrorProne) -> @owned Optional<ErrorProne>
170+
// CHECK-NEXT: [[T2:%.*]] = super_method [volatile] [[T0]] : $VeryErrorProne, #ErrorProne.init!initializer.1.foreign : (ErrorProne.Type) -> (one: Any?) throws -> ErrorProne , $@convention(objc_method) (Optional<AnyObject>, ImplicitlyUnwrappedOptional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, @owned ErrorProne) -> @owned Optional<ErrorProne>
171171
// CHECK: {{$}}
172172
// CHECK-NOT: [[BOX]]{{^[0-9]}}
173173
// CHECK-NOT: [[MARKED_BOX]]{{^[0-9]}}
@@ -189,7 +189,7 @@ func testProtocol(_ p: ErrorProneProtocol) throws {
189189

190190
// rdar://21144509 - Ensure that overrides of replace-with-() imports are possible.
191191
class ExtremelyErrorProne : ErrorProne {
192-
override func conflict3(_ obj: AnyObject, error: ()) throws {}
192+
override func conflict3(_ obj: Any, error: ()) throws {}
193193
}
194194
// CHECK: sil hidden @_TFC14foreign_errors19ExtremelyErrorProne9conflict3{{.*}}
195195
// CHECK: sil hidden [thunk] @_TToFC14foreign_errors19ExtremelyErrorProne9conflict3{{.*}} : $@convention(objc_method) (AnyObject, ImplicitlyUnwrappedOptional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, ExtremelyErrorProne) -> Bool

test/SILGen/lying_about_optional_return_objc.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@ func optionalChainingForeignFunctionTypeProperties(b: BlockProperty?) {
2828
_ = b?.pointerReturning()
2929
// CHECK: unchecked_trivial_bit_cast
3030
_ = b?.constPointerReturning()
31-
// CHECK: unchecked_ref_cast
32-
_ = b?.idReturning()
3331
// CHECK: unchecked_trivial_bit_cast
3432
_ = b?.selectorReturning()
3533
// CHECK: unchecked_ref_cast
3634
_ = b?.objectReturning()
37-
// CHECK: unchecked_ref_cast
38-
_ = b?[b!]
3935

4036
// CHECK: enum $Optional<{{.*}} -> {{.*}}>
4137
_ = b?.voidReturning
@@ -48,12 +44,11 @@ func optionalChainingForeignFunctionTypeProperties(b: BlockProperty?) {
4844
// CHECK: enum $Optional<{{.*}} -> {{.*}}>
4945
_ = b?.constPointerReturning
5046
// CHECK: enum $Optional<{{.*}} -> {{.*}}>
51-
_ = b?.idReturning
52-
// CHECK: enum $Optional<{{.*}} -> {{.*}}>
5347
_ = b?.selectorReturning
5448
// CHECK: enum $Optional<{{.*}} -> {{.*}}>
5549
_ = b?.objectReturning
5650

51+
// CHECK-LABEL: debug_value {{.*}} name "dynamic"
5752
let dynamic: AnyObject? = b!
5853

5954
// CHECK: enum $Optional<()>, #Optional.some!enumelt.1, {{%.*}} : $()
@@ -66,14 +61,10 @@ func optionalChainingForeignFunctionTypeProperties(b: BlockProperty?) {
6661
_ = dynamic?.pointerReturning()
6762
// CHECK: unchecked_trivial_bit_cast
6863
_ = dynamic?.constPointerReturning()
69-
// CHECK: unchecked_ref_cast
70-
_ = dynamic?.idReturning()
7164
// CHECK: unchecked_trivial_bit_cast
7265
_ = dynamic?.selectorReturning()
7366
// CHECK: unchecked_ref_cast
7467
_ = dynamic?.objectReturning()
75-
// CHECK: unchecked_ref_cast
76-
_ = dynamic?[b]
7768
// CHECK: unchecked_trivial_bit_cast
7869
_ = dynamic?.selector
7970

@@ -88,8 +79,6 @@ func optionalChainingForeignFunctionTypeProperties(b: BlockProperty?) {
8879
// CHECK: unchecked_bitwise_cast {{%.*}} : $ImplicitlyUnwrappedOptional<{{.*}} -> {{.*}}> to $Optional<{{.*}} -> {{.*}}>
8980
_ = dynamic?.constPointerReturning
9081
// CHECK: unchecked_bitwise_cast {{%.*}} : $ImplicitlyUnwrappedOptional<{{.*}} -> {{.*}}> to $Optional<{{.*}} -> {{.*}}>
91-
_ = dynamic?.idReturning
92-
// CHECK: unchecked_bitwise_cast {{%.*}} : $ImplicitlyUnwrappedOptional<{{.*}} -> {{.*}}> to $Optional<{{.*}} -> {{.*}}>
9382
_ = dynamic?.selectorReturning
9483
// CHECK: unchecked_bitwise_cast {{%.*}} : $ImplicitlyUnwrappedOptional<{{.*}} -> {{.*}}> to $Optional<{{.*}} -> {{.*}}>
9584
_ = dynamic?.objectReturning
@@ -104,12 +93,8 @@ func optionalChainingForeignFunctionTypeProperties(b: BlockProperty?) {
10493
_ = dynamic?.pointerReturning?()
10594
// CHECK: unchecked_trivial_bit_cast
10695
_ = dynamic?.constPointerReturning?()
107-
// CHECK: unchecked_ref_cast
108-
_ = dynamic?.idReturning?()
10996
// CHECK: unchecked_trivial_bit_cast
11097
_ = dynamic?.selectorReturning?()
111-
// CHECK: unchecked_ref_cast
112-
_ = dynamic?.idReturning?()
11398
_ = dynamic?.objectReturning?()
11499

115100

test/SILGen/objc_blocks_bridging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Test: NSObject {
113113
func clearDraggingItemImageComponentsProvider(_ x: DraggingItem) {
114114
x.imageComponentsProvider = {}
115115
}
116-
// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] @_TTRXFo__oGSaPs9AnyObject___XFdCb__aGSqCSo7NSArray__
116+
// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] @_TTRXFo__oGSaP___XFdCb__aGSqCSo7NSArray__
117117
// CHECK: [[CONVERT:%.*]] = function_ref @_TFE10FoundationSa19_bridgeToObjectiveCfT_CSo7NSArray
118118
// CHECK: [[CONVERTED:%.*]] = apply [[CONVERT]]
119119
// CHECK: [[OPTIONAL:%.*]] = enum $Optional<NSArray>, #Optional.some!enumelt.1, [[CONVERTED]]

0 commit comments

Comments
 (0)