File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -5478,6 +5478,11 @@ bool VarDecl::isPropertyWrapperInitializedWithInitialValue() const {
5478
5478
// If there is no initializer, the initialization form depends on
5479
5479
// whether the property wrapper type has an init(initialValue:).
5480
5480
if (!isParentInitialized ()) {
5481
+ // If it's default-initializable, that doesn't use an initial value.
5482
+ if (auto *PBD = getParentPatternBinding ())
5483
+ if (PBD->isDefaultInitializable ())
5484
+ return false ;
5485
+
5481
5486
auto wrapperTypeInfo = getAttachedPropertyWrapperTypeInfo ();
5482
5487
return wrapperTypeInfo.initialValueInit != nullptr ;
5483
5488
}
Original file line number Diff line number Diff line change @@ -269,6 +269,34 @@ extension ClassUsingWrapper {
269
269
}
270
270
}
271
271
272
+ //
273
+ @_propertyWrapper
274
+ struct WrapperWithDefaultInit < T> {
275
+ private var storage : T ?
276
+
277
+ init ( ) {
278
+ self . storage = nil
279
+ }
280
+
281
+ init ( initialValue: T ) {
282
+ self . storage = initialValue
283
+ }
284
+
285
+ var value : T {
286
+ get { return storage! }
287
+ set { storage = newValue }
288
+ }
289
+ }
290
+
291
+ class UseWrapperWithDefaultInit {
292
+ @WrapperWithDefaultInit var name : String
293
+ }
294
+
295
+ // CHECK-LABEL: sil hidden [transparent] [ossa] @$s17property_wrappers25UseWrapperWithDefaultInitC5$name33_F728088E0028E14D18C6A10CF68512E8LLAA0defG0VySSGvpfi : $@convention(thin) () -> @owned WrapperWithDefaultInit<String>
296
+ // CHECK: function_ref @$s17property_wrappers22WrapperWithDefaultInitVACyxGycfC
297
+ // CHECK: return {{%.*}} : $WrapperWithDefaultInit<String>
298
+
299
+
272
300
// CHECK-LABEL: sil_vtable ClassUsingWrapper {
273
301
// CHECK: #ClassUsingWrapper.x!getter.1: (ClassUsingWrapper) -> () -> Int : @$s17property_wrappers17ClassUsingWrapperC1xSivg // ClassUsingWrapper.x.getter
274
302
// CHECK: #ClassUsingWrapper.x!setter.1: (ClassUsingWrapper) -> (Int) -> () : @$s17property_wrappers17ClassUsingWrapperC1xSivs // ClassUsingWrapper.x.setter
You can’t perform that action at this time.
0 commit comments