@@ -170,16 +170,33 @@ 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+ PropertyWrapperAuxiliaryVariables () {}
185+
186+ PropertyWrapperAuxiliaryVariables (VarDecl *backingVar, VarDecl *projectionVar)
187+ : backingVar(backingVar), projectionVar(projectionVar) {}
188+
189+ // / Whether this is a valid property wrapper.
190+ bool isValid () const {
191+ return backingVar != nullptr ;
192+ }
193+
194+ explicit operator bool () const { return isValid (); }
195+ };
196+
197+ // / Describes how to initialize the backing storage of a property with
198+ // / an attached wrapper.
199+ class PropertyWrapperInitializerInfo {
183200 struct {
184201 // / An expression that initializes the backing property from a value of
185202 // / the original property's type via \c init(wrappedValue:) if supported
@@ -203,15 +220,10 @@ struct PropertyWrapperBackingPropertyInfo {
203220 } projectedValueInit;
204221
205222public:
206- PropertyWrapperBackingPropertyInfo () { }
207-
208- PropertyWrapperBackingPropertyInfo (VarDecl *backingVar, VarDecl *projectionVar)
209- : backingVar(backingVar), projectionVar(projectionVar) { }
223+ PropertyWrapperInitializerInfo () { }
210224
211- PropertyWrapperBackingPropertyInfo (VarDecl *backingVar, VarDecl *projectionVar,
212- Expr *wrappedValueInitExpr,
213- Expr *projectedValueInitExpr)
214- : backingVar(backingVar), projectionVar(projectionVar) {
225+ PropertyWrapperInitializerInfo (Expr *wrappedValueInitExpr,
226+ Expr *projectedValueInitExpr) {
215227 wrappedValueInit.expr = wrappedValueInitExpr;
216228 if (wrappedValueInitExpr) {
217229 wrappedValueInit.placeholder = findWrappedValuePlaceholder (wrappedValueInitExpr);
@@ -223,16 +235,11 @@ struct PropertyWrapperBackingPropertyInfo {
223235 }
224236 }
225237
226- // / Whether this is a valid property wrapper.
227- bool isValid () const {
228- return backingVar != nullptr ;
229- }
230-
231238 bool hasInitFromWrappedValue () const {
232239 return wrappedValueInit.expr != nullptr ;
233240 }
234241
235- Expr *getInitFromWrappedValue () {
242+ Expr *getInitFromWrappedValue () const {
236243 return wrappedValueInit.expr ;
237244 }
238245
@@ -244,7 +251,7 @@ struct PropertyWrapperBackingPropertyInfo {
244251 return projectedValueInit.expr != nullptr ;
245252 }
246253
247- Expr *getInitFromProjectedValue () {
254+ Expr *getInitFromProjectedValue () const {
248255 return projectedValueInit.expr ;
249256 }
250257
@@ -255,14 +262,6 @@ struct PropertyWrapperBackingPropertyInfo {
255262 bool hasSynthesizedInitializers () const {
256263 return hasInitFromWrappedValue () || hasInitFromProjectedValue ();
257264 }
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- }
266265};
267266
268267void simple_display (
@@ -271,7 +270,11 @@ void simple_display(
271270
272271void simple_display (
273272 llvm::raw_ostream &out,
274- const PropertyWrapperBackingPropertyInfo &backingInfo);
273+ const PropertyWrapperInitializerInfo &initInfo);
274+
275+ void simple_display (
276+ llvm::raw_ostream &out,
277+ const PropertyWrapperAuxiliaryVariables &auxiliaryVars);
275278
276279} // end namespace swift
277280
0 commit comments