// RUN: %target-swift-frontend -emit-sil -O -primary-file %s | %FileCheck %s protocol P {} extension P { @_semantics("optimize.sil.never") func method1() {} @inline(__always) func method2() { method1() } } class C : P { // CHECK-LABEL: sil shared [always_inline] @_T023specialize_dynamic_self1CC11returnsSelfACyxGXDyFSi_Tg5 : $@convention(method) (@guaranteed C) -> @owned C // CHECK: [[RESULT:%.*]] = alloc_stack $C // CHECK: [[FN:%.*]] = function_ref @_T023specialize_dynamic_self1PPAAE7method1yyF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () // CHECK: apply [[FN]]<@dynamic_self C>([[RESULT]]) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () // CHECK: return %0 : $C @inline(__always) final func returnsSelf() -> Self { method2() return self } } // CHECK-LABEL: sil hidden [thunk] [always_inline] @_T023specialize_dynamic_self8usesCIntyAA1CCySiG1c_tF : $@convention(thin) (@owned C) -> () { // CHECK: function_ref @_T023specialize_dynamic_self1CC11returnsSelfACyxGXDyFSi_Tg5 : $@convention(method) (@guaranteed C) -> @owned C // CHECK: return func usesCInt(c: C) { _ = c.returnsSelf() }