// swift-compiler-version: Swift 4.0 // swift-module-flags: // RUN: %empty-directory(%t) // RUN: %target-swift-frontend -emit-module-path %t/Conformances.swiftmodule -enable-library-evolution -Xllvm -sil-print-types -emit-sil -o %t/Conformances.sil -enable-objc-interop -disable-objc-attr-requires-foundation-module %s // RUN: %target-swift-frontend -enable-objc-interop -Xllvm -sil-print-types -emit-sil -I %t %S/Inputs/ConformancesUser.swift -O | %FileCheck %s public protocol MyProto { init() func method() var prop: Int { get set } subscript(index: Int) -> Int { get set } } extension MyProto { public func method() {} } // Make sure there's no default witness table. (But also make sure we printed at // least some regular witness tables, or we'll have to change the test.) // CHECK-MODULE: sil_witness_table{{.+}}: MyProto module Conformances // NEGATIVE-MODULE-NOT: sil_default_witness_table{{.+}}MyProto @frozen // allow conformance devirtualization public struct FullStructImpl: MyProto { public init() public func method() public var prop: Int { get set } public subscript(index: Int) -> Int { get set } } // CHECK-LABEL: sil @$s16ConformancesUser8testFullSiyF // CHECK: function_ref @$s12Conformances14FullStructImplVACycfC // CHECK: function_ref @$s12Conformances14FullStructImplV6methodyyF // CHECK: function_ref @$s12Conformances14FullStructImplV4propSivs // CHECK: function_ref @$s12Conformances14FullStructImplVyS2icig // CHECK: end sil function '$s16ConformancesUser8testFullSiyF' @frozen // allow conformance devirtualization public struct OpaqueStructImpl: MyProto {} // CHECK-LABEL: sil @$s16ConformancesUser10testOpaqueSiyF // CHECK: witness_method $OpaqueStructImpl, #MyProto.init!allocator // Note the default implementation is filled in here. // CHECK: witness_method $OpaqueStructImpl, #MyProto.method // CHECK: witness_method $OpaqueStructImpl, #MyProto.prop!setter // CHECK: witness_method $OpaqueStructImpl, #MyProto.subscript!getter // CHECK: end sil function '$s16ConformancesUser10testOpaqueSiyF' @objc public protocol OptionalReqs { @objc optional func method() } @_fixed_layout public final class OptionalReqsPresent: OptionalReqs { public func method () {} } @_fixed_layout public final class OptionalReqsAbsent: OptionalReqs {} // It would be okay if this one got optimized... // CHECK-LABEL: sil @$s16ConformancesUser19testOptionalPresentySb0A00d4ReqsE0CF // CHECK: dynamic_method_br %0 : $OptionalReqsPresent, #OptionalReqs.method!foreign // CHECK: end sil function '$s16ConformancesUser19testOptionalPresentySb0A00d4ReqsE0CF' // ...but not this one, because the method that's currently absent might get added. // CHECK-LABEL: sil @$s16ConformancesUser18testOptionalAbsentySb0A00d4ReqsE0CF // CHECK: dynamic_method_br %0 : $OptionalReqsAbsent, #OptionalReqs.method!foreign // CHECK: end sil function '$s16ConformancesUser18testOptionalAbsentySb0A00d4ReqsE0CF'