mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Always perform override checking based on the Swift type signatures, rather than alternately relying on the Objective-C selectors. This ensures that we get consistent override behavior for @objc vs. non-@objc declarations throughout, and we separately make sure that the Objective-C names line up. This also allows us to inherit @objc'ness correctly (which didn't quite work before), including inferring the Objective-C selector/name (the actual subject of rdar://problem/18998564). Fixes rdar://problem/18998564. Swift SVN r25392
60 lines
1.6 KiB
Swift
60 lines
1.6 KiB
Swift
// RUN: %target-swift-frontend -emit-silgen -sdk %S/Inputs/ -I %S/Inputs -enable-source-import %s | FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
import objc_extensions_helper
|
|
|
|
class Sub : Base {}
|
|
|
|
extension Sub {
|
|
override var prop: String! {
|
|
didSet {
|
|
println("set!")
|
|
}
|
|
// CHECK-LABEL: sil hidden [transparent] @_TToFC15objc_extensions3Subg4propGSQSS_
|
|
// CHECK: = super_method [volatile] %1 : $Sub, #Base.prop!setter.1.foreign
|
|
// CHECK: = function_ref @_TFC15objc_extensions3SubW4propGSQSS_
|
|
// CHECK: }
|
|
}
|
|
|
|
func foo() {
|
|
}
|
|
}
|
|
|
|
// CHECK-LABEL: sil hidden @_TF15objc_extensions20testOverridePropertyFCS_3SubT_
|
|
func testOverrideProperty(obj: Sub) {
|
|
// CHECK: = function_ref @_TFC15objc_extensions3Subs4propGSQSS_
|
|
obj.prop = "abc"
|
|
} // CHECK: }
|
|
|
|
testOverrideProperty(Sub())
|
|
|
|
// CHECK-LABEL: sil shared @_TFC15objc_extensions3Sub3fooFS0_FT_T_
|
|
// CHECK: function_ref @_TTDFC15objc_extensions3Sub3foofS0_FT_T_
|
|
// CHECK: sil shared [transparent] @_TTDFC15objc_extensions3Sub3foofS0_FT_T_
|
|
// CHECK: class_method [volatile] %0 : $Sub, #Sub.foo!1.foreign
|
|
func testCurry(x: Sub) {
|
|
let _ = x.foo
|
|
}
|
|
|
|
extension Sub {
|
|
var otherProp: String {
|
|
get { return "hello" }
|
|
set { }
|
|
}
|
|
}
|
|
|
|
class SubSub : Sub { }
|
|
|
|
extension SubSub {
|
|
// CHECK-LABEL: sil hidden @_TFC15objc_extensions6SubSubs9otherPropSS
|
|
// CHECK: = super_method [volatile] %1 : $SubSub, #Sub.otherProp!getter.1.foreign
|
|
// CHECK: = super_method [volatile] %1 : $SubSub, #Sub.otherProp!setter.1.foreign
|
|
override var otherProp: String {
|
|
didSet {
|
|
println("set!")
|
|
}
|
|
}
|
|
}
|