// RUN: %empty-directory(%t) // RUN: %target-swift-frontend -emit-module -o %t -enable-library-evolution %S/Inputs/def_structA.swift // This uses '-primary-file' to ensure we're conservative with lazy SIL emission. // RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -primary-file %s -I %t | %FileCheck %s import def_structA public struct Projection { public var wrappedValue: T } @propertyWrapper public struct Wrapper { public var wrappedValue: T // CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter7WrapperV12wrappedValueACyxGx_tcfC : $@convention(method) (@in T, @thin Wrapper.Type) -> @out Wrapper public init(wrappedValue: T) { self.wrappedValue = wrappedValue } public var projectedValue: Projection { Projection(wrappedValue: wrappedValue) } // CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter7WrapperV14projectedValueACyxGAA10ProjectionVyxG_tcfC : $@convention(method) (@in Projection, @thin Wrapper.Type) -> @out Wrapper public init(projectedValue: Projection) { self.wrappedValue = projectedValue.wrappedValue } } // property wrapper backing initializer of value #1 in testSimpleWrapperParameter(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_SivpfP : $@convention(thin) (Int) -> Wrapper // property wrapper init from projected value of value #1 in testSimpleWrapperParameter(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_SivpfW : $@convention(thin) (Projection) -> Wrapper // CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tF : $@convention(thin) (Wrapper) -> () public func testSimpleWrapperParameter(@Wrapper value: Int) { _ = value _ = _value _ = $value // getter of $value #1 in testSimpleWrapperParameter(value:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tF6$valueL_AA10ProjectionVySiGvg : $@convention(thin) (Wrapper) -> Projection // getter of value #1 in testSimpleWrapperParameter(value:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_Sivg : $@convention(thin) (Wrapper) -> Int } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter28simpleWrapperParameterCaller10projectionyAA10ProjectionVySiG_tF : $@convention(thin) (Projection) -> () func simpleWrapperParameterCaller(projection: Projection) { testSimpleWrapperParameter(value: projection.wrappedValue) // CHECK: function_ref @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_SivpfP : $@convention(thin) (Int) -> Wrapper testSimpleWrapperParameter($value: projection) // CHECK: function_ref @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_SivpfW : $@convention(thin) (Projection) -> Wrapper var x: Int = 10 testSimpleWrapperParameter(value: x) // CHECK: function_ref @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_SivpfP : $@convention(thin) (Int) -> Wrapper } // property wrapper backing initializer of value #1 in testGenericWrapper(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfP : $@convention(thin) (@in T) -> @out Wrapper // property wrapper init from projected value of value #1 in testGenericWrapper(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfW : $@convention(thin) (@in Projection) -> @out Wrapper // CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlF : $@convention(thin) (@in_guaranteed Wrapper) -> () public func testGenericWrapper(@Wrapper value: T) { } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter20genericWrapperCaller10projectionyAA10ProjectionVySiG_tF : $@convention(thin) (Projection) -> () func genericWrapperCaller(projection: Projection) { testGenericWrapper(value: projection.wrappedValue) // CHECK: function_ref @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfP : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @out Wrapper<τ_0_0> testGenericWrapper($value: projection) // CHECK: function_ref @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfW : $@convention(thin) <τ_0_0> (@in Projection<τ_0_0>) -> @out Wrapper<τ_0_0> var x: Int = 10 testGenericWrapper(value: x) // CHECK: function_ref @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfP : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @out Wrapper<τ_0_0> } @propertyWrapper struct ImplementationDetail { var wrappedValue: T // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter20ImplementationDetailV12wrappedValueACyxGx_tcfC : $@convention(method) (@in T, @thin ImplementationDetail.Type) -> @out ImplementationDetail init(wrappedValue: T) { self.wrappedValue = wrappedValue } } struct TestStructInit { // property wrapper backing initializer of number #1 in TestStructInit.init(number:message:) // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfP : $@convention(thin) (Int) -> Wrapper // property wrapper init from projected value of number #1 in TestStructInit.init(number:message:) // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfW : $@convention(thin) (Projection) -> Wrapper // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfC : $@convention(method) (Wrapper, @owned String, @thin TestStructInit.Type) -> TestStructInit init(@Wrapper number: Int, @ImplementationDetail message: String) { // CHECK: debug_value %0 : $Wrapper, let, name "_number" // CHECK: debug_value [[STR:%.*]] : $String, let, name "message" // CHECK: alloc_stack $ImplementationDetail // CHECK: begin_borrow [[STR]] // CHECK" function_ref @$s26property_wrapper_parameter20ImplementationDetailV12wrappedValueACyxGx_tcfC : $@convention(method) <τ_0_0> (@in τ_0_0, @thin ImplementationDetail<τ_0_0>.Type) -> @out ImplementationDetail<τ_0_0> _ = number _ = _number _ = message _ = _message // getter of number #1 in TestStructInit.init(number:message:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcADL_Sivg : $@convention(thin) (Wrapper) -> Int // getter of message #1 in TestStructInit.init(number:message:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcAEL_SSvg : $@convention(thin) (@guaranteed ImplementationDetail) -> @owned String } } class TestClassInit { // property wrapper backing initializer of number #1 in TestClassInit.init(number:message:) // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfP : $@convention(thin) (Int) -> Wrapper // property wrapper init from projected value of number #1 in TestClassInit.init(number:message:) // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfW : $@convention(thin) (Projection) -> Wrapper // TestClassInit.__allocating_init(number:message:) // CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfC : $@convention(method) (Wrapper, @owned String, @thick TestClassInit.Type) -> @owned TestClassInit // CHECK-NOT: alloc_stack $ImplementationDetail // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfc : $@convention(method) (Wrapper, @owned String, @owned TestClassInit) -> @owned TestClassInit init(@Wrapper number: Int, @ImplementationDetail message: String) { // CHECK: debug_value %0 : $Wrapper, let, name "_number" // CHECK: debug_value [[STR:%.*]] : $String, let, name "message" // CHECK: alloc_stack $ImplementationDetail // CHECK: begin_borrow [[STR]] _ = number _ = _number _ = message _ = _message // getter of number #1 in TestClassInit.init(number:message:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcADL_Sivg : $@convention(thin) (Wrapper) -> Int // getter of message #1 in TestClassInit.init(number:message:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcAEL_SSvg : $@convention(thin) (@guaranteed ImplementationDetail) -> @owned String } } @propertyWrapper public struct AutoClosureWrapper { public var wrappedValue: T // CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter18AutoClosureWrapperV12wrappedValueACyxGxyXK_tcfC : $@convention(method) (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for , @thin AutoClosureWrapper.Type) -> @out AutoClosureWrapper public init(wrappedValue: @autoclosure () -> T) { self.wrappedValue = wrappedValue() } public var projectedValue: Projection { Projection(wrappedValue: wrappedValue) } public init(projectedValue: Projection) { self.wrappedValue = projectedValue.wrappedValue } } // property wrapper backing initializer of value #1 in testAutoClosureWrapper(value:) // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter22testAutoClosureWrapper5valueyAA0efG0VyxG_tlFACL_xvpfP : $@convention(thin) (@owned @noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for ) -> @out AutoClosureWrapper // CHECK: function_ref @$s26property_wrapper_parameter18AutoClosureWrapperV12wrappedValueACyxGxyXK_tcfC : $@convention(method) <τ_0_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <τ_0_0>, @thin AutoClosureWrapper<τ_0_0>.Type) -> @out AutoClosureWrapper<τ_0_0> // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter22testAutoClosureWrapper5valueyAA0efG0VyxG_tlF : $@convention(thin) (@in_guaranteed AutoClosureWrapper) -> () func testAutoClosureWrapper(@AutoClosureWrapper value: T) { } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter24autoClosureWrapperCalleryyF : $@convention(thin) () -> () func autoClosureWrapperCaller() { testAutoClosureWrapper(value: 10) // CHECK: function_ref @$s26property_wrapper_parameter22testAutoClosureWrapper5valueyAA0efG0VyxG_tlFACL_xvpfP : $@convention(thin) <τ_0_0> (@owned @noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <τ_0_0>) -> @out AutoClosureWrapper<τ_0_0> } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter33testSimpleClosureWrapperParameteryyF : $@convention(thin) () -> () func testSimpleClosureWrapperParameter() { let closure: (Int) -> Void = { (@Wrapper value) in _ = value _ = _value _ = $value } closure(10) // implicit closure #1 in testSimpleClosureWrapperParameter() // CHECK: sil private [ossa] @$s26property_wrapper_parameter33testSimpleClosureWrapperParameteryyFySicfu_ : $@convention(thin) (Int) -> () // closure #1 in implicit closure #1 in testSimpleClosureWrapperParameter() // CHECK: sil private [ossa] @$s26property_wrapper_parameter33testSimpleClosureWrapperParameteryyFySicfu_yAA0G0VySiGcfU_ : $@convention(thin) (Wrapper) -> () // property wrapper backing initializer of value #1 in closure #1 in implicit closure #1 in testSimpleClosureWrapperParameter() // CHECK: sil private [ossa] @$s26property_wrapper_parameter33testSimpleClosureWrapperParameteryyFySicfu_yAA0G0VySiGcfU_5valueL_SivpfP : $@convention(thin) (Int) -> Wrapper // getter of $value #1 in closure #1 in implicit closure #1 in testSimpleClosureWrapperParameter() // CHECK: sil private [ossa] @$s26property_wrapper_parameter33testSimpleClosureWrapperParameteryyFySicfu_yAA0G0VySiGcfU_6$valueL_AA10ProjectionVySiGvg : $@convention(thin) (Wrapper) -> Projection // getter of value #1 in closure #1 in implicit closure #1 in testSimpleClosureWrapperParameter() // CHECK: sil private [ossa] @$s26property_wrapper_parameter33testSimpleClosureWrapperParameteryyFySicfu_yAA0G0VySiGcfU_5valueL_Sivg : $@convention(thin) (Wrapper) -> Int } @propertyWrapper struct NonMutatingSetterWrapper { private var value: Value var wrappedValue: Value { get { value } nonmutating set { } } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter24NonMutatingSetterWrapperV12wrappedValueACyxGx_tcfC : $@convention(method) (@in Value, @thin NonMutatingSetterWrapper.Type) -> @out NonMutatingSetterWrapper init(wrappedValue: Value) { self.value = wrappedValue } } @propertyWrapper class ClassWrapper { var wrappedValue: Value // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter12ClassWrapperC12wrappedValueACyxGx_tcfc : $@convention(method) (@in Value, @owned ClassWrapper) -> @owned ClassWrapper init(wrappedValue: Value) { self.wrappedValue = wrappedValue } } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter21testNonMutatingSetter6value16value2ySS_SitF : $@convention(thin) (@guaranteed String, Int) -> () func testNonMutatingSetter(@NonMutatingSetterWrapper value1: String, @ClassWrapper value2: Int) { // CHECK: function_ref @$s26property_wrapper_parameter24NonMutatingSetterWrapperV12wrappedValueACyxGx_tcfC : $@convention(method) <τ_0_0> (@in τ_0_0, @thin NonMutatingSetterWrapper<τ_0_0>.Type) -> @out NonMutatingSetterWrapper<τ_0_0> // CHECK: debug_value {{.*}} : $NonMutatingSetterWrapper, let, name "_value1" // CHECK: function_ref @$s26property_wrapper_parameter12ClassWrapperC12wrappedValueACyxGx_tcfC : $@convention(method) <τ_0_0> (@in τ_0_0, @thick ClassWrapper<τ_0_0>.Type) -> @owned ClassWrapper<τ_0_0> // CHECK: debug_value {{.*}} : $ClassWrapper, let, name "_value2" _ = value1 value1 = "hello!" // getter of value1 #1 in testNonMutatingSetter(value1:value2:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter21testNonMutatingSetter6value16value2ySS_SitFACL_SSvg : $@convention(thin) (@guaranteed NonMutatingSetterWrapper) -> @owned String // setter of value1 #1 in testNonMutatingSetter(value1:value2:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter21testNonMutatingSetter6value16value2ySS_SitFACL_SSvs : $@convention(thin) (@owned String, @guaranteed NonMutatingSetterWrapper) -> () _ = value2 value2 = 10 // getter of value2 #1 in testNonMutatingSetter(value1:value2:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter21testNonMutatingSetter6value16value2ySS_SitFADL_Sivg : $@convention(thin) (@guaranteed ClassWrapper) -> Int // setter of value2 #1 in testNonMutatingSetter(value1:value2:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter21testNonMutatingSetter6value16value2ySS_SitFADL_Sivs : $@convention(thin) (Int, @guaranteed ClassWrapper) -> () } @propertyWrapper struct ProjectionWrapper { var wrappedValue: Value var projectedValue: ProjectionWrapper { self } init(wrappedValue: Value) { self.wrappedValue = wrappedValue } init(projectedValue: ProjectionWrapper) { self.wrappedValue = projectedValue.wrappedValue } } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tF : $@convention(thin) (ProjectionWrapper) -> () func testImplicitPropertyWrapper(projection: ProjectionWrapper) { let multiStatement: (ProjectionWrapper) -> Void = { $value in _ = value _ = _value _ = $value } multiStatement(projection) // implicit closure #1 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFyAFcfu_ : $@convention(thin) (ProjectionWrapper) -> () // closure #1 in implicit closure #1 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFyAFcfu_yAFcfU_ : $@convention(thin) (ProjectionWrapper) -> () // property wrapper init from projected value of $value #1 in closure #1 in implicit closure #1 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFyAFcfu_yAFcfU_6$valueL_AFvpfW : $@convention(thin) (ProjectionWrapper) -> ProjectionWrapper // getter of $value #1 in closure #1 in implicit closure #1 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFyAFcfu_yAFcfU_6$valueL_AFvg : $@convention(thin) (ProjectionWrapper) -> ProjectionWrapper // getter of value #1 in closure #1 in implicit closure #1 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFyAFcfu_yAFcfU_5valueL_Sivg : $@convention(thin) (ProjectionWrapper) -> Int let _: (ProjectionWrapper) -> (Int, ProjectionWrapper) = { $value in (value, $value) } // implicit closure #2 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFSi_AFtAFcfu0_ : $@convention(thin) (ProjectionWrapper) -> (Int, ProjectionWrapper) // closure #2 in implicit closure #2 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFSi_AFtAFcfu0_Si_AFtAFcfU0_ : $@convention(thin) (ProjectionWrapper) -> (Int, ProjectionWrapper) // property wrapper init from projected value of $value #1 in closure #2 in implicit closure #2 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFSi_AFtAFcfu0_Si_AFtAFcfU0_6$valueL_AFvpfW : $@convention(thin) (ProjectionWrapper) -> ProjectionWrapper // getter of $value #1 in closure #2 in implicit closure #2 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFSi_AFtAFcfu0_Si_AFtAFcfU0_6$valueL_AFvg : $@convention(thin) (ProjectionWrapper) -> ProjectionWrapper // getter of value #1 in closure #2 in implicit closure #2 in testImplicitPropertyWrapper(projection:) // CHECK: sil private [ossa] @$s26property_wrapper_parameter27testImplicitPropertyWrapper10projectionyAA010ProjectionG0VySiG_tFSi_AFtAFcfu0_Si_AFtAFcfU0_5valueL_Sivg : $@convention(thin) (ProjectionWrapper) -> Int } protocol P {} // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlF : $@convention(thin) (@in_guaranteed T) -> () func genericContext(_: T) where T: P { let _: (ProjectionWrapper) -> Void = { $value in } // implicit closure #1 in genericContext(_:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlFyAA17ProjectionWrapperVySiGcfu_ : $@convention(thin) (ProjectionWrapper) -> () // This property wrapper generator function should _not_ have a generic signature, // because the closure doesn't have one. // property wrapper init from projected value of $value #1 in closure #1 in implicit closure #1 in genericContext(_:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlFyAA17ProjectionWrapperVySiGcfu_yAFcfU_6$valueL_AFvpfW : $@convention(thin) (ProjectionWrapper) -> ProjectionWrapper let _: (ProjectionWrapper) -> T = { $value in fatalError() } // implicit closure #2 in genericContext(_:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlFxAA17ProjectionWrapperVySiGcfu0_ : $@convention(thin) (ProjectionWrapper) -> @out T // This property wrapper generator function _should_ have a generic signature, because // the closure does have one. // property wrapper init from projected value of $value #1 in closure #2 in implicit closure #2 in genericContext(_:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlFxAA17ProjectionWrapperVySiGcfu0_xAFcfU0_6$valueL_AFvpfW : $@convention(thin) (ProjectionWrapper) -> ProjectionWrapper // property wrapper backing initializer of a #1 in inner #1 (a:) in genericContext(_:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlF5innerL_1ayAA7WrapperVySiG_tAaCRzlFAEL_SivpfP : $@convention(thin) (Int) -> Wrapper // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlF5innerL_1ayAA7WrapperVySiG_tAaCRzlF : $@convention(thin) (Wrapper) -> () func inner(@Wrapper a: Int) {} inner(a: 1) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlF5innerL0_yyAaCRzlF : $@convention(thin) () -> () func inner() { _ = T.self } // property wrapper backing initializer of b #1 in inner #3 (b:) in genericContext(_:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlF5innerL1_1byAA7WrapperVySiG_tAaCRzlFAEL_SivpfP : $@convention(thin) (Int) -> Wrapper // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14genericContextyyxAA1PRzlF5innerL1_1byAA7WrapperVySiG_tAaCRzlF : $@convention(thin) (Wrapper) -> () func inner(@Wrapper b: Int) { inner() } inner(b: 1) } struct HasPrivate { // property wrapper backing initializer of x #1 in HasPrivate.testPrivateWrapper(x:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter10HasPrivateV04testE7Wrapper{{.*}}LL1xyAA0G0VySiG_tFAFL_SivpfP : $@convention(thin) (Int) -> Wrapper // property wrapper init from projected value of x #1 in HasPrivate.testPrivateWrapper(x:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter10HasPrivateV04testE7Wrapper{{.*}}LL1xyAA0G0VySiG_tFAFL_SivpfW : $@convention(thin) (Projection) -> Wrapper // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter10HasPrivateV04testE7Wrapper{{.*}}LL1xyAA0G0VySiG_tF : $@convention(method) (Wrapper, HasPrivate) -> () private func testPrivateWrapper(@Wrapper x: Int) {} // property wrapper backing initializer of x #1 in HasPrivate.testFilePrivateWrapper(x:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter10HasPrivateV08testFileE7Wrapper{{.*}}LL1xyAA0H0VySiG_tFAFL_SivpfP : $@convention(thin) (Int) -> Wrapper // property wrapper init from projected value of x #1 in HasPrivate.testFilePrivateWrapper(x:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter10HasPrivateV08testFileE7Wrapper{{.*}}LL1xyAA0H0VySiG_tFAFL_SivpfW : $@convention(thin) (Projection) -> Wrapper // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter10HasPrivateV08testFileE7Wrapper{{.*}}LL1xyAA0H0VySiG_tF : $@convention(method) (Wrapper, HasPrivate) -> () fileprivate func testFilePrivateWrapper(@Wrapper x: Int) {} func usesWrapperFunctions() { // These are needed to ensure we emit the backing initializers. Otherwise // lazy SILGen emission is happy to drop them. testPrivateWrapper(x: 0) testPrivateWrapper($x: Projection(wrappedValue: 0)) testFilePrivateWrapper(x: 0) testFilePrivateWrapper($x: Projection(wrappedValue: 0)) } } @propertyWrapper public struct PublicWrapper { public var wrappedValue: T public init(wrappedValue: T) { self.wrappedValue = wrappedValue } public var projectedValue: PublicWrapper { return self } public init(projectedValue: PublicWrapper) { self.wrappedValue = projectedValue.wrappedValue } } // property wrapper backing initializer of value #1 in publicFunc(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter10publicFunc5valueyAA13PublicWrapperVySSG_tFACL_SSvpfP : $@convention(thin) (@owned String) -> @owned PublicWrapper // property wrapper init from projected value of value #1 in publicFunc(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter10publicFunc5valueyAA13PublicWrapperVySSG_tFACL_SSvpfW : $@convention(thin) (@owned PublicWrapper) -> @owned PublicWrapper // CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter10publicFunc5valueyAA13PublicWrapperVySSG_tF : $@convention(thin) (@guaranteed PublicWrapper) -> () public func publicFunc(@PublicWrapper value: String) { } // property wrapper backing initializer of value #1 in inlinableFunc(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter13inlinableFunc5valueyAA13PublicWrapperVySSG_tFACL_SSvpfP : $@convention(thin) (@owned String) -> @owned PublicWrapper // property wrapper init from projected value of value #1 in inlinableFunc(value:) // CHECK: sil non_abi [serialized] [ossa] @$s26property_wrapper_parameter13inlinableFunc5valueyAA13PublicWrapperVySSG_tFACL_SSvpfW : $@convention(thin) (@owned PublicWrapper) -> @owned PublicWrapper // CHECK-LABEL: sil [serialized] [ossa] @$s26property_wrapper_parameter13inlinableFunc5valueyAA13PublicWrapperVySSG_tF : $@convention(thin) (@guaranteed PublicWrapper) -> () @inlinable func inlinableFunc(@PublicWrapper value: String) { _ = publicFunc(value:) // implicit closure #1 in inlinableFunc(value:) // CHECK: sil shared [serialized] [ossa] @$s26property_wrapper_parameter13inlinableFunc5valueyAA13PublicWrapperVySSG_tFySScfu_ : $@convention(thin) (@guaranteed String) -> () // CHECK: function_ref @$s26property_wrapper_parameter10publicFunc5valueyAA13PublicWrapperVySSG_tFACL_SSvpfP : $@convention(thin) (@owned String) -> @owned PublicWrapper // CHECK: function_ref @$s26property_wrapper_parameter10publicFunc5valueyAA13PublicWrapperVySSG_tF : $@convention(thin) (@guaranteed PublicWrapper) -> () // property wrapper init from projected value of $x #1 in closure #1 in implicit closure #1 in inlinableFunc(value:) // CHECK: sil shared [serialized] [ossa] @$s26property_wrapper_parameter13inlinableFunc5valueyAA13PublicWrapperVySSG_tFyAEySiGcfu0_yAGcfU_2$xL_AGvpfW : $@convention(thin) (PublicWrapper) -> PublicWrapper let _: (PublicWrapper) -> Void = { $x in } } @propertyWrapper struct NonmutatingSetter { var wrappedValue: Value { // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter17NonmutatingSetterV12wrappedValuexvg : $@convention(method) (NonmutatingSetter) -> @out Value get { fatalError() } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter17NonmutatingSetterV12wrappedValuexvs : $@convention(method) (@in Value, NonmutatingSetter) -> () nonmutating set {} } var projectedValue: Self { self } init(wrappedValue: Value) {} init(projectedValue: Self) {} } func genericClosure(arg: T, _ closure: (T) -> Int) {} // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter30testNonmutatingSetterSynthesis5valueyAA0eF0VySiG_tF : $@convention(thin) (NonmutatingSetter) -> () func testNonmutatingSetterSynthesis(@NonmutatingSetter value: Int) { genericClosure(arg: $value) { $value in (value = 10, value).1 } // closure #1 in implicit closure #1 in testNonmutatingSetterSynthesis(value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter30testNonmutatingSetterSynthesis5valueyAA0eF0VySiG_tFSiAFcfu_SiAFcfU_ : $@convention(thin) (NonmutatingSetter) -> Int // CHECK: function_ref @$s26property_wrapper_parameter30testNonmutatingSetterSynthesis5valueyAA0eF0VySiG_tFSiAFcfu_SiAFcfU_ACL_Sivs : $@convention(thin) (Int, NonmutatingSetter) -> () // CHECK: function_ref @$s26property_wrapper_parameter30testNonmutatingSetterSynthesis5valueyAA0eF0VySiG_tFSiAFcfu_SiAFcfU_ACL_Sivg : $@convention(thin) (NonmutatingSetter) -> Int // CHECK: return // getter of value #1 in closure #1 in implicit closure #1 in testNonmutatingSetterSynthesis(value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter30testNonmutatingSetterSynthesis5valueyAA0eF0VySiG_tFSiAFcfu_SiAFcfU_ACL_Sivg : $@convention(thin) (NonmutatingSetter) -> Int // CHECK: function_ref @$s26property_wrapper_parameter17NonmutatingSetterV12wrappedValuexvg : $@convention(method) <τ_0_0> (NonmutatingSetter<τ_0_0>) -> @out τ_0_0 // setter of value #1 in closure #1 in implicit closure #1 in testNonmutatingSetterSynthesis(value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter30testNonmutatingSetterSynthesis5valueyAA0eF0VySiG_tFSiAFcfu_SiAFcfU_ACL_Sivs : $@convention(thin) (Int, NonmutatingSetter) -> () // CHECK: function_ref @$s26property_wrapper_parameter17NonmutatingSetterV12wrappedValuexvs : $@convention(method) <τ_0_0> (@in τ_0_0, NonmutatingSetter<τ_0_0>) -> () } // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter38testImplicitWrapperWithResilientStructyyF : $@convention(thin) () -> () func testImplicitWrapperWithResilientStruct() { let _: (ProjectionWrapper) -> Void = { $value in } // implicit closure #1 in testImplicitWrapperWithResilientStruct() // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter38testImplicitWrapperWithResilientStructyyFyAA010ProjectionF0Vy11def_structA1AVGcfu_ : $@convention(thin) (@in_guaranteed ProjectionWrapper) -> () // CHECK: [[P:%.*]] = alloc_stack $ProjectionWrapper // CHECK: copy_addr %0 to [init] [[P]] // CHECK: [[I:%.*]] = function_ref @$s26property_wrapper_parameter38testImplicitWrapperWithResilientStructyyFyAA010ProjectionF0Vy11def_structA1AVGcfu_yAHcfU_6$valueL_AHvpfW : $@convention(thin) (@in ProjectionWrapper) -> @out ProjectionWrapper // CHECK: apply [[I]]({{.*}}, [[P]]) : $@convention(thin) (@in ProjectionWrapper) -> @out ProjectionWrapper // property wrapper init from projected value of $value #1 in closure #1 in implicit closure #1 in testImplicitWrapperWithResilientStruct() // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter38testImplicitWrapperWithResilientStructyyFyAA010ProjectionF0Vy11def_structA1AVGcfu_yAHcfU_6$valueL_AHvpfW : $@convention(thin) (@in ProjectionWrapper) -> @out ProjectionWrapper } func takesAutoclosure(_: @autoclosure () -> Int) {} // CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtF : $@convention(thin) (Int, Wrapper) -> () func testCaptures(@ClassWrapper ref: Int, @Wrapper value: Int) { takesAutoclosure(ref) // implicit closure #1 in testCaptures(ref:value:) // CHECK-LABEL: sil private [transparent] [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtFSiyXEfu_ : $@convention(thin) (@guaranteed ClassWrapper) -> Int let _: () -> Void = { _ = ref ref = 100 } // closure #1 in testCaptures(ref:value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtFyycfU_ : $@convention(thin) (@guaranteed ClassWrapper) -> () let _: () -> Projection = { $value } // closure #2 in testCaptures(ref:value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtFAA10ProjectionVySiGycfU0_ : $@convention(thin) (Wrapper) -> Projection let _: (ProjectionWrapper) -> Void = { $x in _ = { x } _ = { $x } } // Make sure there are 4 closures here with the right arguments // implicit closure #2 in testCaptures(ref:value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtFyAA010ProjectionH0VySiGcfu0_ : $@convention(thin) (ProjectionWrapper) -> () // closure #3 in implicit closure #2 in testCaptures(ref:value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtFyAA010ProjectionH0VySiGcfu0_yAJcfU1_ : $@convention(thin) (ProjectionWrapper) -> () // closure #1 in closure #2 in implicit closure #2 in testCaptures(ref:value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtFyAA010ProjectionH0VySiGcfu0_yAJcfU1_SiycfU_ : $@convention(thin) (ProjectionWrapper) -> Int // closure #2 in closure #2 in implicit closure #2 in testCaptures(ref:value:) // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter12testCaptures3ref5valueySi_AA7WrapperVySiGtFyAA010ProjectionH0VySiGcfu0_yAJcfU1_AJycfU0_ : $@convention(thin) (ProjectionWrapper) -> ProjectionWrapper } do { @propertyWrapper struct Binding { var wrappedValue: Value { get { fatalError() } nonmutating set { } } var projectedValue: Self { self } init(projectedValue: Self) { self = projectedValue } } final class Value { enum Kind { } var kind: Binding { fatalError() } } struct Test { var value: Value // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter4TestL_V4test5otheryAA7BindingL_VyAA5ValueL_C4KindOG_tF : $@convention(method) (Binding, @guaranteed Test) -> () // CHECK: [[CHECK_PROJECTED_VALUE_INIT_1:%.*]] = function_ref @$s26property_wrapper_parameter4TestL_V9checkKind4kindyAA7BindingL_VyAA5ValueL_C0F0OG_tFAEL_AKvpfW // CHECK-NEXT: {{.*}} = apply [[CHECK_PROJECTED_VALUE_INIT_1]]({{.*}}) : $@convention(thin) (Binding) -> Binding // CHECK: [[CHECK_PROJECTED_VALUE_INIT_A:%.*]] = function_ref @$s26property_wrapper_parameter4TestL_V15doubleCheckKind1a1byAA7BindingL_VyAA5ValueL_C0G0OG_AMtFAEL_ALvpfW // CHECK-NEXT: {{.*}} = apply [[CHECK_PROJECTED_VALUE_INIT_A]]({{.*}}) : $@convention(thin) (Binding) -> Binding // CHECK: [[CHECK_PROJECTED_VALUE_INIT_B:%.*]] = function_ref @$s26property_wrapper_parameter4TestL_V15doubleCheckKind1a1byAA7BindingL_VyAA5ValueL_C0G0OG_AMtFAFL_ALvpfW // CHECK-NEXT: {{.*}} = apply [[CHECK_PROJECTED_VALUE_INIT_B]]({{.*}}) : $@convention(thin) (Binding) -> Binding func test(other: Binding) { checkKind($kind: value.kind) // Ok doubleCheckKind($a: value.kind, $b: other) // Ok } func checkKind(@Binding kind: Value.Kind) {} func doubleCheckKind(@Binding a: Value.Kind, @Binding b: Value.Kind) {} } }