14
14
15
15
//--- Lib.swift
16
16
package protocol PkgProto {
17
- var pkgVar : String { get }
17
+ /// Key path getter for a protocol property has a shared linkage as below, and a function referencing
18
+ /// this getter (as well as this getter) should not be serialized in Package CMO, even if the `witness_method`
19
+ /// in this getter has package or public access level.
20
+ // key path getter for PkgProto.pkgVar : <A>A
21
+ // sil shared [thunk] @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <T where T : PkgProto> (@in_guaranteed T) -> @out String {
22
+ // [%0: noescape **, write v**]
23
+ // [%1: read v**, write v**, copy v**, destroy v**]
24
+ // [global: read,write,copy,destroy,allocate,deinit_barrier]
25
+ // // %0 // user: %4
26
+ // // %1 // user: %3
27
+ // bb0(%0 : $*String, %1 : $*T):
28
+ // %2 = witness_method $T, #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %3
29
+ // %3 = apply %2<T>(%1) : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %4
30
+ // store %3 to %0 : $*String // id: %4
31
+ // %5 = tuple () // user: %6
32
+ // return %5 : $() // id: %6
33
+ // } // end sil function '$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK'
34
+ var pkgVar : String { get }
35
+
36
+ // key path getter for PkgProto.pkgVar : <A>A
37
+ // CHECK-NOT: sil [serialized_for_package] [thunk] [canonical] @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <T where T : PkgProto> (@in_guaranteed T) -> @out String {
38
+ // CHECK-NOT: witness_method $T, #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %3
39
+ // CHECK-NOT: // end sil function '$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK'
18
40
}
19
41
20
42
package struct Foo : PkgProto {
21
- package var pkgVar : String {
22
- return " Foo pkgVar "
23
- }
43
+ package var pkgVar : String {
44
+ return " Foo pkgVar "
45
+ }
24
46
}
25
47
48
+ /// testKeyPath references the keypath getter above, s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK,
49
+ /// and should not be serialized.
26
50
// testKeyPath<A>(_:)
27
51
// CHECK-NOT: sil package [serialized_for_package] [canonical] @$s3Lib11testKeyPathys0cD0CyxSSGSayxGAA8PkgProtoRzlF : $@convention(thin) <T where T : PkgProto> (@guaranteed Array<T>) -> @owned KeyPath<T, String> {
28
52
// CHECK-NOT: keypath $KeyPath<T, String>, <τ_0_0 where τ_0_0 : PkgProto> (root $τ_0_0; gettable_property $String, id #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String, getter @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @out String) <T>
@@ -31,11 +55,6 @@ package func testKeyPath<T: PkgProto>(_ array: [T]) -> KeyPath<T, String> {
31
55
return \T . pkgVar
32
56
}
33
57
34
- // key path getter for PkgProto.pkgVar : <A>A
35
- // CHECK-NOT: sil [serialized_for_package] [thunk] [canonical] @$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK : $@convention(keypath_accessor_getter) <T where T : PkgProto> (@in_guaranteed T) -> @out String {
36
- // CHECK-NOT: witness_method $T, #PkgProto.pkgVar!getter : <Self where Self : PkgProto> (Self) -> () -> String : $@convention(witness_method: PkgProto) <τ_0_0 where τ_0_0 : PkgProto> (@in_guaranteed τ_0_0) -> @owned String // user: %3
37
- // CHECK-NOT: // end sil function '$s3Lib8PkgProtoP6pkgVarSSvpAaBRzlxTK'
38
-
39
58
// CHECK: sil_witness_table package [serialized_for_package] Foo: PkgProto module Lib {
40
59
// CHECK: method #PkgProto.pkgVar!getter: <Self where Self : PkgProto> (Self) -> () -> String : @$s3Lib3FooVAA8PkgProtoA2aDP6pkgVarSSvgTW
41
60
0 commit comments