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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
// RUN: %target-swift-frontend -parse-as-library -module-name witness_tables -emit-module -o - %s | %target-sil-opt -module-name witness_tables | %FileCheck %s
protocol AssocReqt {
func requiredMethod()
}
struct ConformingAssoc : AssocReqt {
func requiredMethod()
}
sil [serialized] @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@convention(method) (ConformingAssoc) -> () {
bb0(%0 : $ConformingAssoc):
debug_value %0 : $ConformingAssoc
%2 = tuple ()
return %2 : $()
}
sil [serialized] @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_ : $@convention(witness_method: AssocReqt) (@inout ConformingAssoc) -> () {
bb0(%0 : $*ConformingAssoc):
%1 = load %0 : $*ConformingAssoc
%2 = function_ref @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@convention(method) (ConformingAssoc) -> ()
%3 = apply %2(%1) : $@convention(method) (ConformingAssoc) -> ()
return %3 : $()
}
// CHECK-LABEL: sil_witness_table [serialized] ConformingAssoc: AssocReqt module witness_tables {
// CHECK: #AssocReqt.requiredMethod: {{.*}} : @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_
// CHECK: }
sil_witness_table [serialized] ConformingAssoc: AssocReqt module witness_tables {
method #AssocReqt.requiredMethod: @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_
}
protocol AnyProtocol {
associatedtype AssocType
associatedtype AssocWithReqt : AssocReqt
func assocTypesMethod(x: AssocType, y: AssocWithReqt)
static func staticMethod(x: Self)
}
class SomeAssoc {
}
protocol InheritedProtocol1 : AnyProtocol {
func inheritedMethod()
}
struct InheritedConformance : InheritedProtocol1 {
typealias AssocType = SomeAssoc
typealias AssocWithReqt = ConformingAssoc
func assocTypesMethod(x: SomeAssoc, y: ConformingAssoc)
static func staticMethod(x: InheritedConformance)
func inheritedMethod()
}
struct InheritedConformance2 : InheritedProtocol1 {
typealias AssocType = SomeAssoc
typealias AssocWithReqt = ConformingAssoc
func assocTypesMethod(x: SomeAssoc, y: ConformingAssoc)
static func staticMethod(x: InheritedConformance2)
func inheritedMethod()
}
// CHECK-LABEL: sil_witness_table shared [serialized] InheritedConformance: InheritedProtocol1 module
// CHECK: base_protocol AnyProtocol: InheritedConformance: AnyProtocol module
// CHECK: }
sil_witness_table shared [serialized] InheritedConformance: InheritedProtocol1 module witness_tables {
base_protocol AnyProtocol: InheritedConformance: AnyProtocol module witness_tables
}
// CHECK-LABEL: sil_witness_table shared [serialized] InheritedConformance: AnyProtocol module
// CHECK: associated_type AssocType: SomeAssoc
// CHECK: associated_type_protocol (AssocWithReqt: AssocReqt): ConformingAssoc: AssocReqt module
// CHECK: }
sil_witness_table shared [serialized] InheritedConformance: AnyProtocol module witness_tables {
associated_type AssocType: SomeAssoc
associated_type_protocol (AssocWithReqt: AssocReqt): ConformingAssoc: AssocReqt module witness_tables
}
protocol Proto {
func abc()
}
class DeadMethodClass : Proto {
func abc()
}
// CHECK-LABEL: sil_witness_table [serialized] DeadMethodClass: Proto module witness_tables
// CHECK: method #Proto.abc: {{.*}} : nil
// CHECK: }
sil_witness_table [serialized] DeadMethodClass: Proto module witness_tables {
method #Proto.abc: nil
}
|