@@ -6343,6 +6343,8 @@ Expr *swift::findOriginalPropertyWrapperInitialValue(VarDecl *var,
6343
6343
return { false , E };
6344
6344
6345
6345
if (auto call = dyn_cast<CallExpr>(E)) {
6346
+ ASTContext &ctx = innermostNominal->getASTContext ();
6347
+
6346
6348
// We're looking for an implicit call.
6347
6349
if (!call->isImplicit ())
6348
6350
return { true , E };
@@ -6352,9 +6354,19 @@ Expr *swift::findOriginalPropertyWrapperInitialValue(VarDecl *var,
6352
6354
// property.
6353
6355
if (auto tuple = dyn_cast<TupleExpr>(call->getArg ())) {
6354
6356
if (tuple->getNumElements () > 0 ) {
6355
- auto elem = tuple->getElement (0 );
6356
- if (elem->isImplicit () && isa<CallExpr>(elem)) {
6357
- return { true , E };
6357
+ for (unsigned i : range (tuple->getNumElements ())) {
6358
+ if (tuple->getElementName (i) == ctx.Id_wrappedValue ||
6359
+ tuple->getElementName (i) == ctx.Id_initialValue ) {
6360
+ auto elem = tuple->getElement (i)->getSemanticsProvidingExpr ();
6361
+
6362
+ // Look through autoclosures.
6363
+ if (auto autoclosure = dyn_cast<AutoClosureExpr>(elem))
6364
+ elem = autoclosure->getSingleExpressionBody ();
6365
+
6366
+ if (elem->isImplicit () && isa<CallExpr>(elem)) {
6367
+ return { true , E };
6368
+ }
6369
+ }
6358
6370
}
6359
6371
}
6360
6372
}
@@ -6367,7 +6379,6 @@ Expr *swift::findOriginalPropertyWrapperInitialValue(VarDecl *var,
6367
6379
6368
6380
// Find the implicit initialValue/wrappedValue argument.
6369
6381
if (auto tuple = dyn_cast<TupleExpr>(call->getArg ())) {
6370
- ASTContext &ctx = innermostNominal->getASTContext ();
6371
6382
for (unsigned i : range (tuple->getNumElements ())) {
6372
6383
if (tuple->getElementName (i) == ctx.Id_wrappedValue ||
6373
6384
tuple->getElementName (i) == ctx.Id_initialValue ) {
0 commit comments