|
1 |
| -// RUN: %target-swift-emit-silgen %s | %FileCheck %s |
| 1 | +// RUN: %target-swift-emit-silgen -primary-file %s | %FileCheck %s |
2 | 2 |
|
3 | 3 | // 1. Make sure the wrapped property setter calls the observers
|
4 | 4 | // 2. Make sure the synthesized _modify coroutine calls the wrapped property setter
|
@@ -108,3 +108,34 @@ struct MutatingWillSet {
|
108 | 108 | // CHECK-LABEL: sil private [ossa] @$s26property_wrapper_observers15MutatingWillSetV5value33_{{.*}}Sivs : $@convention(method) (Int, @inout MutatingWillSet) -> () {
|
109 | 109 | // CHECK: function_ref @$s26property_wrapper_observers15MutatingWillSetV5value33_{{.*}}Sivw : $@convention(method) (Int, @inout MutatingWillSet) -> ()
|
110 | 110 | // CHECK: function_ref @$s26property_wrapper_observers5StateV12wrappedValueSivs : $@convention(method) (Int, State) -> ()
|
| 111 | + |
| 112 | +@propertyWrapper struct MutatingGetter { |
| 113 | + var wrappedValue: Int { |
| 114 | + mutating get { |
| 115 | + return 3 |
| 116 | + } |
| 117 | + nonmutating set {} |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +struct HasMutatingGetter { |
| 122 | + @MutatingGetter var hasDidSet: Int { |
| 123 | + didSet {} |
| 124 | + } |
| 125 | + |
| 126 | + @MutatingGetter var hasWillSet: Int { |
| 127 | + willSet {} |
| 128 | + } |
| 129 | +} |
| 130 | + |
| 131 | +// The didSet causes the setter to become mutating: |
| 132 | + |
| 133 | +// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_observers17HasMutatingGetterV9hasDidSetSivg : $@convention(method) (@inout HasMutatingGetter) -> Int { |
| 134 | +// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_observers17HasMutatingGetterV9hasDidSetSivs : $@convention(method) (Int, @inout HasMutatingGetter) -> () { |
| 135 | +// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_observers17HasMutatingGetterV9hasDidSetSivM : $@yield_once @convention(method) (@inout HasMutatingGetter) -> @yields @inout Int { |
| 136 | + |
| 137 | +// The willSet does not: |
| 138 | + |
| 139 | +// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_observers17HasMutatingGetterV10hasWillSetSivg : $@convention(method) (@inout HasMutatingGetter) -> Int { |
| 140 | +// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_observers17HasMutatingGetterV10hasWillSetSivs : $@convention(method) (Int, HasMutatingGetter) -> () { |
| 141 | +// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_observers17HasMutatingGetterV10hasWillSetSivM : $@yield_once @convention(method) (@inout HasMutatingGetter) -> @yields @inout Int { |
0 commit comments