forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextensions_objc.swift
33 lines (26 loc) · 1.04 KB
/
extensions_objc.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// RUN: %target-swift-frontend -sdk %S/Inputs %s -I %S/Inputs -enable-source-import -emit-silgen | %FileCheck %s
//
// REQUIRES: objc_interop
import Foundation
class Foo {}
extension Foo {
dynamic func kay() {}
dynamic var cox: Int { return 0 }
}
// CHECK-LABEL: sil hidden @_TF15extensions_objc19extensionReferencesFCS_3FooT_
func extensionReferences(_ x: Foo) {
// dynamic extension methods are still dynamically dispatched.
// CHECK: class_method [volatile] %0 : $Foo, #Foo.kay!1.foreign
x.kay()
// CHECK: class_method [volatile] %0 : $Foo, #Foo.cox!getter.1.foreign
_ = x.cox
}
func extensionMethodCurrying(_ x: Foo) {
_ = x.kay
}
// CHECK-LABEL: sil shared [thunk] @_TFC15extensions_objc3Foo3kayF
// CHECK: function_ref @_TTDFC15extensions_objc3Foo3kayf
// CHECK-LABEL: sil shared [transparent] [thunk] @_TTDFC15extensions_objc3Foo3kayf
// CHECK: bb0([[SELF:%.*]] : $Foo):
// CHECK: [[SELF_COPY:%.*]] = copy_value [[SELF]]
// CHECK: class_method [volatile] [[SELF_COPY]] : $Foo, #Foo.kay!1.foreign