// RUN: %target-swift-emit-silgen %s | %FileCheck %s protocol P1 { func normal() func generic(_: T) } protocol P2 {} protocol P3 {} protocol P4 { associatedtype AT } struct Conformance {} extension Conformance: P1 where A: P2 { func normal() {} func generic(_: T) {} } // This is defined below but is emitted before any witness tables. // Just make sure it does not have a generic signature. // // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s23conditional_conformance16SameTypeConcreteVyxGAA2P1AASiRszlAaEP6normalyyFTW : $@convention(witness_method: P1) (@in_guaranteed SameTypeConcrete) -> () // CHECK-LABEL: sil_witness_table hidden Conformance: P1 module conditional_conformance { // CHECK-NEXT: method #P1.normal: (Self) -> () -> () : @$s23conditional_conformance11ConformanceVyxGAA2P1A2A2P2RzlAaEP6normalyyFTW // protocol witness for P1.normal() in conformance Conformance // CHECK-NEXT: method #P1.generic: (Self) -> (T) -> () : @$s23conditional_conformance11ConformanceVyxGAA2P1A2A2P2RzlAaEP7genericyyqd__AA2P3Rd__lFTW // protocol witness for P1.generic(_:) in conformance Conformance // CHECK-NEXT: conditional_conformance (A: P2): dependent // CHECK-NEXT: } struct ConformanceAssoc {} extension ConformanceAssoc: P1 where A: P4, A.AT: P2 { func normal() {} func generic(_: T) {} } // CHECK-LABEL: sil_witness_table hidden ConformanceAssoc: P1 module conditional_conformance { // CHECK-NEXT: method #P1.normal: (Self) -> () -> () : @$s23conditional_conformance16ConformanceAssocVyxGAA2P1A2A2P4RzAA2P22ATRpzlAaEP6normalyyFTW // protocol witness for P1.normal() in conformance ConformanceAssoc // CHECK-NEXT: method #P1.generic: (Self) -> (T) -> () : @$s23conditional_conformance16ConformanceAssocVyxGAA2P1A2A2P4RzAA2P22ATRpzlAaEP7genericyyqd__AA2P3Rd__lFTW // protocol witness for P1.generic(_:) in conformance ConformanceAssoc // CHECK-NEXT: conditional_conformance (A: P4): dependent // CHECK-NEXT: conditional_conformance (A.AT: P2): dependent // CHECK-NEXT: } struct SameTypeConcrete {} extension SameTypeConcrete: P1 where B == Int { func normal() {} func generic(_: T) {} } // CHECK-LABEL: sil_witness_table hidden SameTypeConcrete: P1 module conditional_conformance { // CHECK-NEXT: method #P1.normal: (Self) -> () -> () : @$s23conditional_conformance16SameTypeConcreteVyxGAA2P1AASiRszlAaEP6normalyyFTW // protocol witness for P1.normal() in conformance SameTypeConcrete // CHECK-NEXT: method #P1.generic: (Self) -> (T) -> () : @$s23conditional_conformance16SameTypeConcreteVyxGAA2P1AASiRszlAaEP7genericyyqd__AA2P3Rd__lFTW // protocol witness for P1.generic(_:) in conformance SameTypeConcrete // CHECK-NEXT: } struct SameTypeGeneric {} extension SameTypeGeneric: P1 where C == D { func normal() {} func generic(_: T) {} } struct SameTypeGenericConcrete {} extension SameTypeGenericConcrete: P1 where E == [F] { func normal() {} func generic(_: T) {} } struct Everything {} extension Everything: P1 where G: P2, H == Int, I == J, K == [L] { func normal() {} func generic(_: T) {} } struct IsP2: P2 {} struct IsNotP2 {} class Base {} extension Base: P1 where A: P2 { func normal() {} func generic(_: T) {} } // CHECK-LABEL: sil_witness_table hidden Base: P1 module conditional_conformance { // CHECK-NEXT: method #P1.normal: (Self) -> () -> () : @$s23conditional_conformance4BaseCyxGAA2P1A2A2P2RzlAaEP6normalyyFTW // protocol witness for P1.normal() in conformance Base // CHECK-NEXT: method #P1.generic: (Self) -> (T) -> () : @$s23conditional_conformance4BaseCyxGAA2P1A2A2P2RzlAaEP7genericyyqd__AA2P3Rd__lFTW // protocol witness for P1.generic(_:) in conformance Base // CHECK-NEXT: conditional_conformance (A: P2): dependent // CHECK-NEXT: } // These don't get separate witness tables, but shouldn't crash anything. class SubclassGood: Base {} class SubclassBad: Base {}