@@ -1350,9 +1350,7 @@ bool ContextualFailure::diagnoseMissingFunctionCall() const {
1350
1350
.highlight (anchor->getSourceRange ())
1351
1351
.fixItInsertAfter (anchor->getEndLoc (), " ()" );
1352
1352
1353
- if (isa<ClosureExpr>(getAnchor ())) {
1354
- tryComputedPropertyFixIts (TC, anchor, getDC ());
1355
- }
1353
+ tryComputedPropertyFixIts (anchor);
1356
1354
1357
1355
return true ;
1358
1356
}
@@ -1384,8 +1382,10 @@ bool ContextualFailure::trySequenceSubsequenceFixIts(InFlightDiagnostic &diag,
1384
1382
return false ;
1385
1383
}
1386
1384
1387
- void ContextualFailure::tryComputedPropertyFixIts (TypeChecker &TC, Expr *expr,
1388
- DeclContext *dc) {
1385
+ void ContextualFailure::tryComputedPropertyFixIts (Expr *expr) const {
1386
+ if (!isa<ClosureExpr>(expr))
1387
+ return ;
1388
+
1389
1389
// It is possible that we're looking at a stored property being
1390
1390
// initialized with a closure. Something like:
1391
1391
//
@@ -1397,15 +1397,15 @@ void ContextualFailure::tryComputedPropertyFixIts(TypeChecker &TC, Expr *expr,
1397
1397
1398
1398
PatternBindingDecl *PBD = nullptr ;
1399
1399
1400
- if (auto TLCD = dyn_cast<TopLevelCodeDecl>(dc )) {
1400
+ if (auto TLCD = dyn_cast<TopLevelCodeDecl>(getDC () )) {
1401
1401
if (TLCD->getBody ()->isImplicit ()) {
1402
1402
if (auto decl = TLCD->getBody ()->getElement (0 ).dyn_cast <Decl *>()) {
1403
1403
if (auto binding = dyn_cast<PatternBindingDecl>(decl)) {
1404
1404
PBD = binding;
1405
1405
}
1406
1406
}
1407
1407
}
1408
- } else if (auto PBI = dyn_cast<PatternBindingInitializer>(dc )) {
1408
+ } else if (auto PBI = dyn_cast<PatternBindingInitializer>(getDC () )) {
1409
1409
PBD = PBI->getBinding ();
1410
1410
}
1411
1411
@@ -1416,9 +1416,9 @@ void ContextualFailure::tryComputedPropertyFixIts(TypeChecker &TC, Expr *expr,
1416
1416
if (!VD->isStatic () &&
1417
1417
!VD->getAttrs ().getAttribute <DynamicReplacementAttr>() &&
1418
1418
entry.getInit () && isa<ClosureExpr>(entry.getInit ())) {
1419
- auto diag =
1420
- TC. diagnose (expr-> getLoc (), diag::extension_stored_property_fixit,
1421
- VD->getName ());
1419
+ auto diag = emitDiagnostic (expr-> getLoc (),
1420
+ diag::extension_stored_property_fixit,
1421
+ VD->getName ());
1422
1422
diag.fixItRemove (entry.getEqualLoc ());
1423
1423
1424
1424
if (VD->isLet ()) {
0 commit comments