@@ -240,6 +240,61 @@ func partialApplySelfReturn(c: Factory, t: Factory.Type) {
240
240
_ = Factory . staticNewInstance
241
241
}
242
242
243
+ // Super call to a method returning Self
244
+ class Base {
245
+ required init ( ) { }
246
+
247
+ func returnsSelf( ) -> Self {
248
+ return self
249
+ }
250
+
251
+ static func returnsSelfStatic( ) -> Self {
252
+ return self . init ( )
253
+ }
254
+ }
255
+
256
+ class Derived : Base {
257
+ // CHECK-LABEL: sil hidden @_TFC12dynamic_self7Derived9superCallfT_T_ : $@convention(method) (@guaranteed Derived) -> ()
258
+ // CHECK: [[SELF:%.*]] = copy_value %0
259
+ // CHECK: [[SUPER:%.*]] = upcast [[SELF]] : $Derived to $Base
260
+ // CHECK: [[METHOD:%.*]] = function_ref @_TFC12dynamic_self4Base11returnsSelffT_DS0_
261
+ // CHECK: apply [[METHOD]]([[SUPER]])
262
+ // CHECK: return
263
+ func superCall( ) {
264
+ super. returnsSelf ( )
265
+ }
266
+
267
+ // CHECK-LABEL: sil hidden @_TZFC12dynamic_self7Derived15superCallStaticfT_T_ : $@convention(method) (@thick Derived.Type) -> ()
268
+ // CHECK: [[SUPER:%.*]] = upcast %0 : $@thick Derived.Type to $@thick Base.Type
269
+ // CHECK: [[METHOD:%.*]] = function_ref @_TZFC12dynamic_self4Base17returnsSelfStaticfT_DS0_
270
+ // CHECK: apply [[METHOD]]([[SUPER]])
271
+ // CHECK: return
272
+ static func superCallStatic( ) {
273
+ super. returnsSelfStatic ( )
274
+ }
275
+
276
+ // CHECK-LABEL: sil hidden @_TFC12dynamic_self7Derived32superCallFromMethodReturningSelffT_DS0_ : $@convention(method) (@guaranteed Derived) -> @owned Derived
277
+ // CHECK: [[SELF:%.*]] = copy_value %0
278
+ // CHECK: [[SUPER:%.*]] = upcast [[SELF]] : $Derived to $Base
279
+ // CHECK: [[METHOD:%.*]] = function_ref @_TFC12dynamic_self4Base11returnsSelffT_DS0_
280
+ // CHECK: apply [[METHOD]]([[SUPER]])
281
+ // CHECK: return
282
+ func superCallFromMethodReturningSelf( ) -> Self {
283
+ super. returnsSelf ( )
284
+ return self
285
+ }
286
+
287
+ // CHECK-LABEL: sil hidden @_TZFC12dynamic_self7Derived38superCallFromMethodReturningSelfStaticfT_DS0_ : $@convention(method) (@thick Derived.Type) -> @owned Derived
288
+ // CHECK: [[SUPER:%.*]] = upcast %0 : $@thick Derived.Type to $@thick Base.Type
289
+ // CHECK: [[METHOD:%.*]] = function_ref @_TZFC12dynamic_self4Base17returnsSelfStaticfT_DS0_
290
+ // CHECK: apply [[METHOD]]([[SUPER]])
291
+ // CHECK: return
292
+ static func superCallFromMethodReturningSelfStatic( ) -> Self {
293
+ super. returnsSelfStatic ( )
294
+ return self . init ( )
295
+ }
296
+ }
297
+
243
298
// CHECK-LABEL: sil_witness_table hidden X: P module dynamic_self {
244
299
// CHECK: method #P.f!1: @_TTWC12dynamic_self1XS_1PS_FS1_1f
245
300
0 commit comments