Skip to content

Commit 56b0c55

Browse files
committed
[cs] make tryComputedPropertyFixIts() a private instance method
1 parent 3ddffef commit 56b0c55

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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()) {

lib/Sema/CSDiagnostics.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,6 @@ class ContextualFailure final : public FailureDiagnostic {
671671
static bool trySequenceSubsequenceFixIts(InFlightDiagnostic &diag,
672672
ConstraintSystem &CS, Type fromType,
673673
Type toType, Expr *expr);
674-
/// Try to add a fix-it to convert a stored property into a computed
675-
/// property
676-
static void tryComputedPropertyFixIts(TypeChecker &TC, Expr *expr,
677-
DeclContext *dc);
678674

679675
private:
680676
Type resolve(Type rawType) {
@@ -685,6 +681,10 @@ class ContextualFailure final : public FailureDiagnostic {
685681
}
686682
return type;
687683
}
684+
685+
/// Try to add a fix-it to convert a stored property into a computed
686+
/// property
687+
void tryComputedPropertyFixIts(Expr *expr) const;
688688
};
689689

690690
/// Diagnose situations when @autoclosure argument is passed to @autoclosure

0 commit comments

Comments
 (0)