@@ -1350,9 +1350,7 @@ bool ContextualFailure::diagnoseMissingFunctionCall() const {
13501350 .highlight (anchor->getSourceRange ())
13511351 .fixItInsertAfter (anchor->getEndLoc (), " ()" );
13521352
1353- if (isa<ClosureExpr>(getAnchor ())) {
1354- tryComputedPropertyFixIts (TC, anchor, getDC ());
1355- }
1353+ tryComputedPropertyFixIts (anchor);
13561354
13571355 return true ;
13581356}
@@ -1384,8 +1382,10 @@ bool ContextualFailure::trySequenceSubsequenceFixIts(InFlightDiagnostic &diag,
13841382 return false ;
13851383}
13861384
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+
13891389 // It is possible that we're looking at a stored property being
13901390 // initialized with a closure. Something like:
13911391 //
@@ -1397,15 +1397,15 @@ void ContextualFailure::tryComputedPropertyFixIts(TypeChecker &TC, Expr *expr,
13971397
13981398 PatternBindingDecl *PBD = nullptr ;
13991399
1400- if (auto TLCD = dyn_cast<TopLevelCodeDecl>(dc )) {
1400+ if (auto TLCD = dyn_cast<TopLevelCodeDecl>(getDC () )) {
14011401 if (TLCD->getBody ()->isImplicit ()) {
14021402 if (auto decl = TLCD->getBody ()->getElement (0 ).dyn_cast <Decl *>()) {
14031403 if (auto binding = dyn_cast<PatternBindingDecl>(decl)) {
14041404 PBD = binding;
14051405 }
14061406 }
14071407 }
1408- } else if (auto PBI = dyn_cast<PatternBindingInitializer>(dc )) {
1408+ } else if (auto PBI = dyn_cast<PatternBindingInitializer>(getDC () )) {
14091409 PBD = PBI->getBinding ();
14101410 }
14111411
@@ -1416,9 +1416,9 @@ void ContextualFailure::tryComputedPropertyFixIts(TypeChecker &TC, Expr *expr,
14161416 if (!VD->isStatic () &&
14171417 !VD->getAttrs ().getAttribute <DynamicReplacementAttr>() &&
14181418 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 ());
14221422 diag.fixItRemove (entry.getEqualLoc ());
14231423
14241424 if (VD->isLet ()) {
0 commit comments