@@ -973,8 +973,8 @@ class AvailabilityWalker : public ASTWalker {
973973
974974private:
975975 bool diagAvailability (const ValueDecl *D, SourceRange R);
976- bool diagnoseIncDecDeprecation (const ValueDecl *D, SourceRange R,
977- const AvailableAttr *Attr);
976+ bool diagnoseIncDecRemoval (const ValueDecl *D, SourceRange R,
977+ const AvailableAttr *Attr);
978978
979979 // / Walk an assignment expression, checking for availability.
980980 void walkAssignExpr (AssignExpr *E) {
@@ -1090,13 +1090,16 @@ bool AvailabilityWalker::diagAvailability(const ValueDecl *D, SourceRange R) {
10901090 if (!D)
10911091 return false ;
10921092
1093+ if (auto *attr = AvailableAttr::isUnavailable (D))
1094+ if (diagnoseIncDecRemoval (D, R, attr))
1095+ return true ;
1096+
10931097 if (TC.diagnoseExplicitUnavailability (D, R, DC))
10941098 return true ;
10951099
10961100 // Diagnose for deprecation
10971101 if (const AvailableAttr *Attr = TypeChecker::getDeprecated (D)) {
1098- if (!diagnoseIncDecDeprecation (D, R, Attr))
1099- TC.diagnoseDeprecated (R, DC, Attr, D->getFullName ());
1102+ TC.diagnoseDeprecated (R, DC, Attr, D->getFullName ());
11001103 }
11011104
11021105 if (TC.getLangOpts ().DisableAvailabilityChecking )
@@ -1132,11 +1135,11 @@ static bool isIntegerOrFloatingPointType(Type ty, DeclContext *DC,
11321135}
11331136
11341137
1135- // / If this is a call to a deprecated ++ / -- operator, try to diagnose it with
1136- // / a fixit hint and return true. If not, or if we fail, return false.
1137- bool AvailabilityWalker::diagnoseIncDecDeprecation (const ValueDecl *D,
1138- SourceRange R,
1139- const AvailableAttr *Attr) {
1138+ // / If this is a call to an unavailable ++ / -- operator, try to diagnose it
1139+ // / with a fixit hint and return true. If not, or if we fail, return false.
1140+ bool AvailabilityWalker::diagnoseIncDecRemoval (const ValueDecl *D,
1141+ SourceRange R,
1142+ const AvailableAttr *Attr) {
11401143 // We can only produce a fixit if we're talking about ++ or --.
11411144 bool isInc = D->getNameStr () == " ++" ;
11421145 if (!isInc && D->getNameStr () != " --" )
@@ -1171,17 +1174,16 @@ bool AvailabilityWalker::diagnoseIncDecDeprecation(const ValueDecl *D,
11711174
11721175 if (!replacement.empty ()) {
11731176 // If we emit a deprecation diagnostic, produce a fixit hint as well.
1174- TC.diagnoseDeprecated (R, DC, Attr, D->getFullName (),
1175- [&](InFlightDiagnostic &diag) {
1176- if (isa<PrefixUnaryExpr>(call)) {
1177- // Prefix: remove the ++ or --.
1178- diag.fixItRemove (call->getFn ()->getSourceRange ());
1179- diag.fixItInsertAfter (call->getArg ()->getEndLoc (), replacement);
1180- } else {
1181- // Postfix: replace the ++ or --.
1182- diag.fixItReplace (call->getFn ()->getSourceRange (), replacement);
1183- }
1184- });
1177+ auto diag = TC.diagnose (R.Start , diag::availability_decl_unavailable_msg,
1178+ D->getFullName (), " it has been removed in Swift 3" );
1179+ if (isa<PrefixUnaryExpr>(call)) {
1180+ // Prefix: remove the ++ or --.
1181+ diag.fixItRemove (call->getFn ()->getSourceRange ());
1182+ diag.fixItInsertAfter (call->getArg ()->getEndLoc (), replacement);
1183+ } else {
1184+ // Postfix: replace the ++ or --.
1185+ diag.fixItReplace (call->getFn ()->getSourceRange (), replacement);
1186+ }
11851187
11861188 return true ;
11871189 }
0 commit comments