@@ -170,16 +170,39 @@ void simple_display(llvm::raw_ostream &os, PropertyWrapperLValueness l);
170170// / be initialized out-of-line using an expression of the wrapped property type.
171171PropertyWrapperValuePlaceholderExpr *findWrappedValuePlaceholder (Expr *init);
172172
173- // / Describes the backing property of a property that has an attached wrapper.
174- struct PropertyWrapperBackingPropertyInfo {
173+ // / The synthesized auxiliary declarations for a wrapped property, including the
174+ // / backing property wrapper, the projected value variable, and if the wrapped
175+ // / declaration is a parameter, the local wrapped value variable.
176+ struct PropertyWrapperAuxiliaryVariables {
175177 // / The backing property.
176178 VarDecl *backingVar = nullptr ;
177179
178180 // / The synthesized projection property, if any. When present, this takes the name
179181 // / of the original wrapped property prefixed with \c $
180182 VarDecl *projectionVar = nullptr ;
181183
182- private:
184+ // / The synthesized local wrapped value property, which shadows the original wrapped
185+ // / declaration if it is a parameter.
186+ VarDecl *localWrappedValueVar = nullptr ;
187+
188+ PropertyWrapperAuxiliaryVariables () {}
189+
190+ PropertyWrapperAuxiliaryVariables (VarDecl *backingVar, VarDecl *projectionVar,
191+ VarDecl *localWrappedValueVar = nullptr )
192+ : backingVar(backingVar), projectionVar(projectionVar),
193+ localWrappedValueVar (localWrappedValueVar) {}
194+
195+ // / Whether this is a valid property wrapper.
196+ bool isValid () const {
197+ return backingVar != nullptr ;
198+ }
199+
200+ explicit operator bool () const { return isValid (); }
201+ };
202+
203+ // / Describes how to initialize the backing storage of a property with
204+ // / an attached wrapper.
205+ class PropertyWrapperInitializerInfo {
183206 struct {
184207 // / An expression that initializes the backing property from a value of
185208 // / the original property's type via \c init(wrappedValue:) if supported
@@ -203,15 +226,10 @@ struct PropertyWrapperBackingPropertyInfo {
203226 } projectedValueInit;
204227
205228public:
206- PropertyWrapperBackingPropertyInfo () { }
207-
208- PropertyWrapperBackingPropertyInfo (VarDecl *backingVar, VarDecl *projectionVar)
209- : backingVar(backingVar), projectionVar(projectionVar) { }
229+ PropertyWrapperInitializerInfo () { }
210230
211- PropertyWrapperBackingPropertyInfo (VarDecl *backingVar, VarDecl *projectionVar,
212- Expr *wrappedValueInitExpr,
213- Expr *projectedValueInitExpr)
214- : backingVar(backingVar), projectionVar(projectionVar) {
231+ PropertyWrapperInitializerInfo (Expr *wrappedValueInitExpr,
232+ Expr *projectedValueInitExpr) {
215233 wrappedValueInit.expr = wrappedValueInitExpr;
216234 if (wrappedValueInitExpr) {
217235 wrappedValueInit.placeholder = findWrappedValuePlaceholder (wrappedValueInitExpr);
@@ -223,16 +241,11 @@ struct PropertyWrapperBackingPropertyInfo {
223241 }
224242 }
225243
226- // / Whether this is a valid property wrapper.
227- bool isValid () const {
228- return backingVar != nullptr ;
229- }
230-
231244 bool hasInitFromWrappedValue () const {
232245 return wrappedValueInit.expr != nullptr ;
233246 }
234247
235- Expr *getInitFromWrappedValue () {
248+ Expr *getInitFromWrappedValue () const {
236249 return wrappedValueInit.expr ;
237250 }
238251
@@ -244,7 +257,7 @@ struct PropertyWrapperBackingPropertyInfo {
244257 return projectedValueInit.expr != nullptr ;
245258 }
246259
247- Expr *getInitFromProjectedValue () {
260+ Expr *getInitFromProjectedValue () const {
248261 return projectedValueInit.expr ;
249262 }
250263
@@ -255,14 +268,6 @@ struct PropertyWrapperBackingPropertyInfo {
255268 bool hasSynthesizedInitializers () const {
256269 return hasInitFromWrappedValue () || hasInitFromProjectedValue ();
257270 }
258-
259- explicit operator bool () const { return isValid (); }
260-
261- friend bool operator ==(const PropertyWrapperBackingPropertyInfo &lhs,
262- const PropertyWrapperBackingPropertyInfo &rhs) {
263- // FIXME: Can't currently compare expressions.
264- return lhs.backingVar == rhs.backingVar ;
265- }
266271};
267272
268273void simple_display (
@@ -271,7 +276,11 @@ void simple_display(
271276
272277void simple_display (
273278 llvm::raw_ostream &out,
274- const PropertyWrapperBackingPropertyInfo &backingInfo);
279+ const PropertyWrapperInitializerInfo &initInfo);
280+
281+ void simple_display (
282+ llvm::raw_ostream &out,
283+ const PropertyWrapperAuxiliaryVariables &auxiliaryVars);
275284
276285} // end namespace swift
277286
0 commit comments