mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This replaces the '[volatile]' flag. Now, class_method and super_method are only used for vtable dispatch. The witness_method instruction is still overloaded for use with both ObjC protocol requirements and Swift protocol requirements; the next step is to make it only mean the latter, also using objc_method for ObjC protocol calls.
44 lines
2.0 KiB
Swift
44 lines
2.0 KiB
Swift
// RUN: %target-swift-frontend -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership | %FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import gizmo
|
|
|
|
// Although we don't ever expose initializers and methods of generic classes
|
|
// to ObjC yet, a generic subclass of an ObjC class must still use ObjC
|
|
// deallocation.
|
|
|
|
// CHECK-NOT: sil hidden @_T0So7GenericCfd
|
|
// CHECK-NOT: sil hidden @_T0So8NSObjectCfd
|
|
|
|
class Generic<T>: NSObject {
|
|
var x: Int = 10
|
|
|
|
// CHECK-LABEL: sil hidden @_T018objc_generic_class7GenericCfD : $@convention(method) <T> (@owned Generic<T>) -> () {
|
|
// CHECK: bb0({{%.*}} : @owned $Generic<T>):
|
|
// CHECK: } // end sil function '_T018objc_generic_class7GenericCfD'
|
|
// CHECK-LABEL: sil hidden [thunk] @_T018objc_generic_class7GenericCfDTo : $@convention(objc_method) <T> (Generic<T>) -> () {
|
|
// CHECK: bb0([[SELF:%.*]] : @unowned $Generic<T>):
|
|
// CHECK: [[SELF_COPY:%.*]] = copy_value [[SELF]]
|
|
// CHECK: [[NATIVE:%.*]] = function_ref @_T018objc_generic_class7GenericCfD
|
|
// CHECK: apply [[NATIVE]]<T>([[SELF_COPY]])
|
|
// CHECK: } // end sil function '_T018objc_generic_class7GenericCfDTo'
|
|
deinit {
|
|
// Don't blow up when 'self' is referenced inside an @objc deinit method
|
|
// of a generic class. <rdar://problem/16325525>
|
|
self.x = 0
|
|
}
|
|
}
|
|
|
|
// CHECK-NOT: sil hidden @_T018objc_generic_class7GenericCfd
|
|
// CHECK-NOT: sil hidden @_T0So8NSObjectCfd
|
|
|
|
// CHECK-LABEL: sil hidden @_T018objc_generic_class11SubGeneric1CfD : $@convention(method) <U, V> (@owned SubGeneric1<U, V>) -> () {
|
|
// CHECK: bb0([[SELF:%.*]] : @owned $SubGeneric1<U, V>):
|
|
// CHECK: [[SUPER_DEALLOC:%.*]] = objc_super_method [[SELF]] : $SubGeneric1<U, V>, #Generic.deinit!deallocator.foreign : <T> (Generic<T>) -> () -> (), $@convention(objc_method) <τ_0_0> (Generic<τ_0_0>) -> ()
|
|
// CHECK: [[SUPER:%.*]] = upcast [[SELF:%.*]] : $SubGeneric1<U, V> to $Generic<Int>
|
|
// CHECK: apply [[SUPER_DEALLOC]]<Int>([[SUPER]])
|
|
class SubGeneric1<U, V>: Generic<Int> {
|
|
}
|
|
|