Skip to content

Commit 70b0cd5

Browse files
committed
[AST/Sema] TypeWrappers/NFC: Rename type wrapper storage property to $storage
1 parent 0f48f5c commit 70b0cd5

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

include/swift/AST/KnownIdentifiers.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ IDENTIFIER_WITH_NAME(builderSelf, "$builderSelf")
311311

312312
// Type wrappers
313313
IDENTIFIER_WITH_NAME(TypeWrapperStorage, "$Storage")
314-
IDENTIFIER_WITH_NAME(TypeWrapperProperty, "$_storage")
314+
IDENTIFIER_WITH_NAME(TypeWrapperProperty, "$storage")
315315
IDENTIFIER(storageKeyPath)
316316
IDENTIFIER_WITH_NAME(localStorageVar, "_storage")
317317

include/swift/AST/TypeCheckRequests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3588,7 +3588,7 @@ class GetTypeWrapperStorage
35883588
bool isCached() const { return true; }
35893589
};
35903590

3591-
/// Inject or get `$_storage` property which is used to route accesses through
3591+
/// Inject or get `$storage` property which is used to route accesses through
35923592
/// to all stored properties of a type that has a type wrapper.
35933593
class GetTypeWrapperProperty
35943594
: public SimpleRequest<GetTypeWrapperProperty, VarDecl *(NominalTypeDecl *),

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
12491249
auto &ctx = decl->getASTContext();
12501250
// If declaration is type wrapped and there are no
12511251
// designated initializers, synthesize a special
1252-
// memberwise initializer that would instantiate `$_storage`.
1252+
// memberwise initializer that would instantiate `$storage`.
12531253
if (!hasUserDefinedDesignatedInit(ctx.evaluator, decl))
12541254
(void)decl->getTypeWrappedTypeMemberwiseInitializer();
12551255
}

lib/Sema/TypeCheckStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static bool hasStoredProperties(NominalTypeDecl *decl,
107107
static void computeLoweredStoredProperties(NominalTypeDecl *decl,
108108
IterableDeclContext *implDecl) {
109109
// If declaration has a type wrapper, make sure that
110-
// `$_storage` property is synthesized.
110+
// `$storage` property is synthesized.
111111
if (decl->hasTypeWrapper())
112112
(void)decl->getTypeWrapperProperty();
113113

lib/Sema/TypeCheckTypeWrapper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ GetTypeWrapperProperty::evaluate(Evaluator &evaluator,
205205
->castTo<AnyGenericType>();
206206
assert(typeWrapperType);
207207

208-
// $_storage: Wrapper<$Storage>
208+
// $storage: Wrapper<$Storage>
209209
auto propertyTy = BoundGenericType::get(
210210
typeWrapper, /*Parent=*/typeWrapperType->getParent(),
211211
/*genericArgs=*/{storage->getInterfaceType()->getMetatypeInstanceType()});
@@ -240,7 +240,7 @@ VarDecl *GetTypeWrapperStorageForProperty::evaluate(Evaluator &evaluator,
240240
}
241241

242242
/// Given the property create a subscript to reach its type wrapper storage:
243-
/// `$_storage[storageKeyPath: \$Storage.<property>]`.
243+
/// `$storage[storageKeyPath: \$Storage.<property>]`.
244244
static SubscriptExpr *subscriptTypeWrappedProperty(VarDecl *var,
245245
AccessorDecl *useDC) {
246246
auto &ctx = useDC->getASTContext();
@@ -270,7 +270,7 @@ static SubscriptExpr *subscriptTypeWrappedProperty(VarDecl *var,
270270
/*Loc=*/DeclNameLoc(), /*Implicit=*/true),
271271
typeWrapperVar->getName());
272272

273-
// $_storage[storageKeyPath: \$Storage.<property-name>]
273+
// $storage[storageKeyPath: \$Storage.<property-name>]
274274
return SubscriptExpr::create(
275275
ctx, subscriptBaseExpr,
276276
ArgumentList::forImplicitSingle(ctx, ctx.Id_storageKeyPath, argExpr),
@@ -403,7 +403,7 @@ BraceStmt *SynthesizeTypeWrappedTypeMemberwiseInitializerBody::evaluate(
403403
auto &ctx = ctor->getASTContext();
404404
auto *parent = ctor->getDeclContext()->getSelfNominalTypeDecl();
405405

406-
// self.$_storage = .init(storage: $Storage(...))
406+
// self.$storage = .init(storage: $Storage(...))
407407
auto *storageType = parent->getTypeWrapperStorageDecl();
408408
assert(storageType);
409409

test/SILOptimizer/type_wrapper_definite_init_diagnostics.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ do {
4343
}
4444
}
4545

46-
// FIXME: Diagnostics should mention `self.b` or `self.a` and not `self.$_storage`
46+
// FIXME: Diagnostics should mention `self.b` or `self.a` and not `self.$storage`
4747

4848
@Wrapper
4949
struct ImmutableTest3 {
@@ -57,7 +57,7 @@ do {
5757

5858
init(a: Int = 42) {
5959
self.a = a
60-
print(self.a) // expected-error {{'self' used before all stored properties are initialized}} expected-note {{'self.$_storage' not initialized}}
60+
print(self.a) // expected-error {{'self' used before all stored properties are initialized}} expected-note {{'self.$storage' not initialized}}
6161
self.b = ""
6262
}
6363

@@ -74,15 +74,15 @@ do {
7474
if let b = otherB {
7575
self.b = b
7676
}
77-
} // expected-error {{return from initializer without initializing all stored properties}} expected-note {{'self.$_storage' not initialized}}
77+
} // expected-error {{return from initializer without initializing all stored properties}} expected-note {{'self.$storage' not initialized}}
7878

7979
init(optB: String? = nil) {
8080
if let optB {
8181
self.b = optB
82-
print(self.b) // expected-error {{'self' used before all stored properties are initialized}} expected-note {{'self.$_storage' not initialized}}
82+
print(self.b) // expected-error {{'self' used before all stored properties are initialized}} expected-note {{'self.$storage' not initialized}}
8383
} else {
8484
self.b = ""
85-
print(self.b) // expected-error {{'self' used before all stored properties are initialized}} expected-note {{'self.$_storage' not initialized}}
85+
print(self.b) // expected-error {{'self' used before all stored properties are initialized}} expected-note {{'self.$storage' not initialized}}
8686
}
8787

8888
self.a = 0

test/SILOptimizer/type_wrapper_init_transform.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct TrivialStruct {
3434
// CHECK: store [[STORAGE_INIT_RES]] to [trivial] [[STORAGE_INST]] : $*TrivialStruct.$Storage
3535
// CHECK: [[WRAPPER_INIT_REF:%.*]] = function_ref @$s4test7WrapperV7storageACyxGx_tcfC : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
3636
// CHECK: [[SELF_ACCESS:%.*]] = begin_access [modify] [static] %1 : $*TrivialStruct
37-
// CHECK: [[STORAGE_VAR_REF:%.*]] = struct_element_addr [[SELF_ACCESS]] : $*TrivialStruct, #TrivialStruct.$_storage
37+
// CHECK: [[STORAGE_VAR_REF:%.*]] = struct_element_addr [[SELF_ACCESS]] : $*TrivialStruct, #TrivialStruct.$storage
3838
// CHECK: [[WRAPPER_METATYPE:%.*]] = metatype $@thin Wrapper<TrivialStruct.$Storage>.Type
3939
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<TrivialStruct.$Storage>
4040
// CHECK: {{.*}} = apply [[WRAPPER_INIT_REF]]<TrivialStruct.$Storage>([[WRAPPER_INST]], [[STORAGE_INST]], [[WRAPPER_METATYPE]]) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
@@ -68,7 +68,7 @@ struct GenericStruct<T: Collection> {
6868
// CHECK: {{.*}} = apply [[STORAGE_INIT_REF]]<T>([[STORAGE_INST]], [[T_VAL]], [[STORAGE_METATYPE]]) : $@convention(method) <τ_0_0 where τ_0_0 : Collection> (@in τ_0_0, @thin GenericStruct<τ_0_0>.$Storage.Type) -> @out GenericStruct<τ_0_0>.$Storage
6969
// CHECK: [[WRAPPER_INIT_REF:%.*]] = function_ref @$s4test7WrapperV7storageACyxGx_tcfC : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
7070
// CHECK: [[SELF_ACCESS:%.*]] = begin_access [modify] [static] [[SELF]] : $*GenericStruct<T>
71-
// CHECK: [[STORAGE_VAR:%.*]] = struct_element_addr [[SELF_ACCESS]] : $*GenericStruct<T>, #GenericStruct.$_storage
71+
// CHECK: [[STORAGE_VAR:%.*]] = struct_element_addr [[SELF_ACCESS]] : $*GenericStruct<T>, #GenericStruct.$storage
7272
// CHECK: [[WRAPPER_METATYPE:%.*]] = metatype $@thin Wrapper<GenericStruct<T>.$Storage>.Type
7373
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<GenericStruct<T>.$Storage>
7474
// CHECK: {{.*}} = apply [[WRAPPER_INIT_REF]]<GenericStruct<T>.$Storage>([[WRAPPER_INST]], [[STORAGE_INST]], [[WRAPPER_METATYPE]]) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
@@ -90,7 +90,7 @@ class GenericClass<T: Collection> {
9090
// CHECK: [[TEST_PROP:%.*]] = tuple_element_addr [[LOCAL_STORAGE]] : $*(test: T), 0
9191
// CHECK: assign_by_wrapper origin type_wrapper, [[TEST_VAL:%.*]] : $*T to [initialization] [[TEST_PROP]] : $*T, set {{.*}}
9292
// CHECK: [[SELF_ACCESS:%.*]] = begin_borrow [[SELF:%.*]] : $GenericClass<T>
93-
// CHECK-NEXT: [[STORAGE_VAR_REF:%.*]] = ref_element_addr [[SELF_ACCESS]] : $GenericClass<T>, #GenericClass.$_storage
93+
// CHECK-NEXT: [[STORAGE_VAR_REF:%.*]] = ref_element_addr [[SELF_ACCESS]] : $GenericClass<T>, #GenericClass.$storage
9494
// CHECK: {{.*}} = apply [[WRAPPER_INIT_REF:%.*]]<GenericClass<T>.$Storage>([[WRAPPER_INST:%.*]], [[STORAGE_INST:%.*]], {{.*}}) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
9595
// CHECK: [[STORAGE_VAR_ACCESS:%.*]] = begin_access [modify] [dynamic] [[STORAGE_VAR_REF]] : $*Wrapper<GenericClass<T>.$Storage>
9696
// CHECK-NEXT: copy_addr [take] [[WRAPPER_INST]] to [initialization] [[STORAGE_VAR_ACCESS]] : $*Wrapper<GenericClass<T>.$Storage>
@@ -192,7 +192,7 @@ class TestConditionalInjection<T> {
192192
// CHECK: end_access [[LOCAL_STORAGE_ACCESS]] : $*(b: Optional<T>)
193193
// CHECK: {{.*}} = apply [[STORAGE_INIT_REF]]<T>([[STORAGE_INST:%.*]], [[B_VAL]], {{.*}}) : $@convention(method) <τ_0_0> (@in Optional<τ_0_0>, @thin TestConditionalInjection<τ_0_0>.$Storage.Type) -> @out TestConditionalInjection<τ_0_0>.$Storage
194194
// CHECK: [[SELF_ACCESS:%.*]] = begin_borrow [[SELF:%.*]] : $TestConditionalInjection<T>
195-
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$_storage
195+
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$storage
196196
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<TestConditionalInjection<T>.$Storage>
197197
// CHECK: {{.*}} = apply [[WRAPPER_INIT_REF:%.*]]<TestConditionalInjection<T>.$Storage>([[WRAPPER_INST]], [[STORAGE_INST]], {{.*}}) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
198198
// CHECK: [[STORAGE_PROP_ACCESS:%.*]] = begin_access [modify] [dynamic] [[STORAGE_PROP]] : $*Wrapper<TestConditionalInjection<T>.$Storage>
@@ -213,7 +213,7 @@ class TestConditionalInjection<T> {
213213
// CHECK: end_access [[LOCAL_STORAGE_ACCESS]] : $*(b: Optional<T>)
214214
// CHECK: {{.*}} = apply [[STORAGE_INIT_REF]]<T>([[STORAGE_INST:%.*]], [[B_VAL]], {{.*}}) : $@convention(method) <τ_0_0> (@in Optional<τ_0_0>, @thin TestConditionalInjection<τ_0_0>.$Storage.Type) -> @out TestConditionalInjection<τ_0_0>.$Storage
215215
// CHECK: [[SELF_ACCESS:%.*]] = begin_borrow [[SELF:%.*]] : $TestConditionalInjection<T>
216-
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$_storage
216+
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$storage
217217
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<TestConditionalInjection<T>.$Storage>
218218
// CHECK: {{.*}} = apply [[WRAPPER_INIT_REF:%.*]]<TestConditionalInjection<T>.$Storage>([[WRAPPER_INST]], [[STORAGE_INST]], {{.*}}) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
219219
// CHECK: [[STORAGE_PROP_ACCESS:%.*]] = begin_access [modify] [dynamic] [[STORAGE_PROP]] : $*Wrapper<TestConditionalInjection<T>.$Storage>
@@ -251,7 +251,7 @@ class TestConditionalInjection<T> {
251251
// CHECK: end_access [[LOCAL_STORAGE_ACCESS]] : $*(b: Optional<T>)
252252
// CHECK: {{.*}} = apply [[STORAGE_INIT_REF]]<T>([[STORAGE_INST:%.*]], [[B_VAL]], {{.*}}) : $@convention(method) <τ_0_0> (@in Optional<τ_0_0>, @thin TestConditionalInjection<τ_0_0>.$Storage.Type) -> @out TestConditionalInjection<τ_0_0>.$Storage
253253
// CHECK: [[SELF_ACCESS:%.*]] = begin_borrow [[SELF:%.*]] : $TestConditionalInjection<T>
254-
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$_storage
254+
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$storage
255255
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<TestConditionalInjection<T>.$Storage>
256256
// CHECK: {{.*}} = apply [[WRAPPER_INIT_REF:%.*]]<TestConditionalInjection<T>.$Storage>([[WRAPPER_INST]], [[STORAGE_INST]], {{.*}}) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
257257
// CHECK: [[STORAGE_PROP_ACCESS:%.*]] = begin_access [modify] [dynamic] [[STORAGE_PROP]] : $*Wrapper<TestConditionalInjection<T>.$Storage>
@@ -272,7 +272,7 @@ class TestConditionalInjection<T> {
272272
// CHECK: end_access [[LOCAL_STORAGE_ACCESS]] : $*(b: Optional<T>)
273273
// CHECK: {{.*}} = apply [[STORAGE_INIT_REF]]<T>([[STORAGE_INST:%.*]], [[B_VAL]], {{.*}}) : $@convention(method) <τ_0_0> (@in Optional<τ_0_0>, @thin TestConditionalInjection<τ_0_0>.$Storage.Type) -> @out TestConditionalInjection<τ_0_0>.$Storage
274274
// CHECK: [[SELF_ACCESS:%.*]] = begin_borrow [[SELF:%.*]] : $TestConditionalInjection<T>
275-
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$_storage
275+
// CHECK: [[STORAGE_PROP:%.*]] = ref_element_addr [[SELF_ACCESS]] : $TestConditionalInjection<T>, #TestConditionalInjection.$storage
276276
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<TestConditionalInjection<T>.$Storage>
277277
// CHECK: {{.*}} = apply [[WRAPPER_INIT_REF:%.*]]<TestConditionalInjection<T>.$Storage>([[WRAPPER_INST]], [[STORAGE_INST]], {{.*}}) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
278278
// CHECK: [[STORAGE_PROP_ACCESS:%.*]] = begin_access [modify] [dynamic] [[STORAGE_PROP]] : $*Wrapper<TestConditionalInjection<T>.$Storage>
@@ -372,7 +372,7 @@ struct TypeWithLetProperties<T> {
372372
// CHECK-NEXT: {{.*}} = apply [[STORAGE_INIT_REF]]<T>([[STORAGE]], [[T]], [[B_VAL]], [[STORAGE_METATYPE]])
373373

374374
// CHECK: [[WRAPPER_INIT_REF:%.*]] = function_ref @$s4test7WrapperV7storageACyxGx_tcfC
375-
// CHECK: [[STORAGE_PROP:%.*]] = struct_element_addr [[SELF_ACCESS:%.*]] : $*TypeWithLetProperties<T>, #TypeWithLetProperties.$_storage
375+
// CHECK: [[STORAGE_PROP:%.*]] = struct_element_addr [[SELF_ACCESS:%.*]] : $*TypeWithLetProperties<T>, #TypeWithLetProperties.$storage
376376
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<TypeWithLetProperties<T>.$Storage>
377377
// CHECK-NEXT: {{.*}} = apply [[WRAPPER_INIT_REF]]<TypeWithLetProperties<T>.$Storage>([[WRAPPER_INST]], [[STORAGE]], [[WRAPPER_METATYPE:%.*]])
378378

@@ -402,7 +402,7 @@ struct TypeWithLetProperties<T> {
402402
// CHECK-NEXT: {{.*}} = apply [[STORAGE_INIT_REF]]<T>([[STORAGE]], [[T]], [[B_VAL]], [[STORAGE_METATYPE]])
403403

404404
// CHECK: [[WRAPPER_INIT_REF:%.*]] = function_ref @$s4test7WrapperV7storageACyxGx_tcfC
405-
// CHECK: [[STORAGE_PROP:%.*]] = struct_element_addr [[SELF_ACCESS:%.*]] : $*TypeWithLetProperties<T>, #TypeWithLetProperties.$_storage
405+
// CHECK: [[STORAGE_PROP:%.*]] = struct_element_addr [[SELF_ACCESS:%.*]] : $*TypeWithLetProperties<T>, #TypeWithLetProperties.$storage
406406
// CHECK: [[WRAPPER_INST:%.*]] = alloc_stack $Wrapper<TypeWithLetProperties<T>.$Storage>
407407
// CHECK-NEXT: {{.*}} = apply [[WRAPPER_INIT_REF]]<TypeWithLetProperties<T>.$Storage>([[WRAPPER_INST]], [[STORAGE]], [[WRAPPER_METATYPE:%.*]])
408408

0 commit comments

Comments
 (0)