@@ -72,30 +72,6 @@ TypedNode FailureDiagnostic::getAnchor() const {
72
72
return anchor;
73
73
}
74
74
75
- SourceLoc FailureDiagnostic::getLoc (TypedNode anchor) {
76
- if (auto *E = anchor.dyn_cast <const Expr *>()) {
77
- return E->getLoc ();
78
- } else if (auto *T = anchor.dyn_cast <const TypeLoc *>()) {
79
- return T->getLoc ();
80
- } else if (auto *V = anchor.dyn_cast <const VarDecl *>()) {
81
- return V->getNameLoc ();
82
- } else {
83
- return anchor.get <const Pattern *>()->getLoc ();
84
- }
85
- }
86
-
87
- SourceRange FailureDiagnostic::getSourceRange (TypedNode anchor) {
88
- if (auto *E = anchor.dyn_cast <const Expr *>()) {
89
- return E->getSourceRange ();
90
- } else if (auto *T = anchor.dyn_cast <const TypeLoc *>()) {
91
- return T->getSourceRange ();
92
- } else if (auto *V = anchor.dyn_cast <const VarDecl *>()) {
93
- return V->getSourceRange ();
94
- } else {
95
- return anchor.get <const Pattern *>()->getSourceRange ();
96
- }
97
- }
98
-
99
75
Type FailureDiagnostic::getType (TypedNode node, bool wantRValue) const {
100
76
return resolveType (S.getType (node), /* reconstituteSugar=*/ false , wantRValue);
101
77
}
@@ -734,7 +710,7 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
734
710
if (!diagnostic)
735
711
return false ;
736
712
737
- emitDiagnosticAt (getLoc (anchor), *diagnostic, fromType, toType);
713
+ emitDiagnosticAt (:: getLoc (anchor), *diagnostic, fromType, toType);
738
714
emitNotesForMismatches ();
739
715
return true ;
740
716
}
@@ -2580,7 +2556,7 @@ bool ContextualFailure::tryRawRepresentableFixIts(
2580
2556
if (conformsToKnownProtocol (CS, fromType, KnownProtocolKind::OptionSet) &&
2581
2557
isExpr<IntegerLiteralExpr>(anchor) &&
2582
2558
castToExpr<IntegerLiteralExpr>(anchor)->getDigitsText () == " 0" ) {
2583
- diagnostic.fixItReplace (getSourceRange (anchor), " []" );
2559
+ diagnostic.fixItReplace (:: getSourceRange (anchor), " []" );
2584
2560
return true ;
2585
2561
}
2586
2562
if (auto rawTy = isRawRepresentable (CS, toType, rawRepresentableProtocol)) {
@@ -3045,7 +3021,7 @@ TypedNode MissingCallFailure::getAnchor() const {
3045
3021
3046
3022
bool MissingCallFailure::diagnoseAsError () {
3047
3023
auto anchor = getAnchor ();
3048
- SourceLoc insertLoc = getSourceRange (anchor ).End ;
3024
+ SourceLoc insertLoc = getSourceRange ().End ;
3049
3025
3050
3026
// Calls are not yet supported by key path, but it
3051
3027
// is useful to record this fix to diagnose chaining
@@ -3063,7 +3039,7 @@ bool MissingCallFailure::diagnoseAsError() {
3063
3039
case ConstraintLocator::ApplyArgToParam: {
3064
3040
auto fnType = getType (anchor)->castTo <FunctionType>();
3065
3041
emitDiagnostic (diag::missing_nullary_call, fnType->getResult ())
3066
- .fixItInsertAfter (getSourceRange (). End , " ()" );
3042
+ .fixItInsertAfter (insertLoc , " ()" );
3067
3043
return true ;
3068
3044
}
3069
3045
@@ -3142,7 +3118,7 @@ bool ExtraneousPropertyWrapperUnwrapFailure::diagnoseAsError() {
3142
3118
}
3143
3119
3144
3120
bool MissingPropertyWrapperUnwrapFailure::diagnoseAsError () {
3145
- auto endLoc = getLoc (getAnchor () ).getAdvancedLoc (1 );
3121
+ auto endLoc = getLoc ().getAdvancedLoc (1 );
3146
3122
3147
3123
if (auto *member = getReferencedMember ()) {
3148
3124
emitDiagnostic (diag::incorrect_property_wrapper_reference_member,
@@ -3238,7 +3214,7 @@ bool MissingMemberFailure::diagnoseAsError() {
3238
3214
3239
3215
auto baseType = resolveType (getBaseType ())->getWithoutSpecifierType ();
3240
3216
3241
- DeclNameLoc nameLoc (FailureDiagnostic ::getLoc (anchor));
3217
+ DeclNameLoc nameLoc (::getLoc (anchor));
3242
3218
if (auto *UDE = getAsExpr<UnresolvedDotExpr>(anchor)) {
3243
3219
nameLoc = UDE->getNameLoc ();
3244
3220
} else if (auto *UME = getAsExpr<UnresolvedMemberExpr>(anchor)) {
@@ -3336,8 +3312,7 @@ bool MissingMemberFailure::diagnoseAsError() {
3336
3312
emitBasicError (baseType);
3337
3313
}
3338
3314
} else if (auto moduleTy = baseType->getAs <ModuleType>()) {
3339
- emitDiagnosticAt (FailureDiagnostic::getLoc (memberBase),
3340
- diag::no_member_of_module,
3315
+ emitDiagnosticAt (::getLoc (memberBase), diag::no_member_of_module,
3341
3316
moduleTy->getModule ()->getName (), getName ())
3342
3317
.highlight (getSourceRange ())
3343
3318
.highlight (nameLoc.getSourceRange ());
@@ -4740,7 +4715,7 @@ bool InaccessibleMemberFailure::diagnoseAsError() {
4740
4715
return false ;
4741
4716
}
4742
4717
4743
- auto loc = nameLoc.isValid () ? nameLoc.getStartLoc () : getLoc (anchor);
4718
+ auto loc = nameLoc.isValid () ? nameLoc.getStartLoc () : :: getLoc (anchor);
4744
4719
auto accessLevel = Member->getFormalAccessScope ().accessLevelForDiagnostics ();
4745
4720
if (auto *CD = dyn_cast<ConstructorDecl>(Member)) {
4746
4721
emitDiagnosticAt (loc, diag::init_candidate_inaccessible,
@@ -4764,7 +4739,7 @@ SourceLoc AnyObjectKeyPathRootFailure::getLoc() const {
4764
4739
return rootTyRepr->getLoc ();
4765
4740
}
4766
4741
4767
- return FailureDiagnostic ::getLoc (anchor);
4742
+ return ::getLoc (anchor);
4768
4743
}
4769
4744
4770
4745
SourceRange AnyObjectKeyPathRootFailure::getSourceRange () const {
@@ -4775,7 +4750,7 @@ SourceRange AnyObjectKeyPathRootFailure::getSourceRange() const {
4775
4750
return rootTyRepr->getSourceRange ();
4776
4751
}
4777
4752
4778
- return FailureDiagnostic ::getSourceRange (anchor);
4753
+ return ::getSourceRange (anchor);
4779
4754
}
4780
4755
4781
4756
bool AnyObjectKeyPathRootFailure::diagnoseAsError () {
@@ -4813,7 +4788,7 @@ SourceLoc InvalidMemberRefInKeyPath::getLoc() const {
4813
4788
return KPE->getComponents ()[component->getIndex ()].getLoc ();
4814
4789
}
4815
4790
4816
- return FailureDiagnostic ::getLoc (anchor);
4791
+ return ::getLoc (anchor);
4817
4792
}
4818
4793
4819
4794
bool InvalidStaticMemberRefInKeyPath::diagnoseAsError () {
@@ -4840,7 +4815,7 @@ SourceLoc InvalidUseOfAddressOf::getLoc() const {
4840
4815
if (auto *assign = getAsExpr<AssignExpr>(anchor))
4841
4816
return assign->getSrc ()->getLoc ();
4842
4817
4843
- return FailureDiagnostic ::getLoc (anchor);
4818
+ return ::getLoc (anchor);
4844
4819
}
4845
4820
4846
4821
bool InvalidUseOfAddressOf::diagnoseAsError () {
@@ -5509,7 +5484,7 @@ bool ArgumentMismatchFailure::diagnoseAsError() {
5509
5484
if (getType (argument, /* wantRValue=*/ false )->is <LValueType>()) {
5510
5485
auto elementTy = paramType->getAnyPointerElementType ();
5511
5486
if (elementTy && argType->isEqual (elementTy)) {
5512
- diag.fixItInsert (getSourceRange (argument).Start , " &" );
5487
+ diag.fixItInsert (:: getSourceRange (argument).Start , " &" );
5513
5488
return true ;
5514
5489
}
5515
5490
}
@@ -5965,8 +5940,8 @@ bool NonEphemeralConversionFailure::diagnosePointerInit() const {
5965
5940
: diag::cannot_construct_dangling_pointer;
5966
5941
5967
5942
auto anchor = getRawAnchor ();
5968
- emitDiagnosticAt (getLoc (anchor), diagID, constructedTy, constructorKind)
5969
- .highlight (getSourceRange (anchor));
5943
+ emitDiagnosticAt (:: getLoc (anchor), diagID, constructedTy, constructorKind)
5944
+ .highlight (:: getSourceRange (anchor));
5970
5945
5971
5946
emitSuggestionNotes ();
5972
5947
return true ;
@@ -6155,7 +6130,7 @@ getImportModuleAndDefaultType(const ASTContext &ctx,
6155
6130
}
6156
6131
6157
6132
SourceLoc UnableToInferProtocolLiteralType::getLoc () const {
6158
- return FailureDiagnostic ::getLoc (getRawAnchor ());
6133
+ return ::getLoc (getRawAnchor ());
6159
6134
}
6160
6135
6161
6136
bool UnableToInferProtocolLiteralType::diagnoseAsError () {
0 commit comments