Skip to content

Commit ce61dfe

Browse files
committed
[Diagnostics] NFC: Couple of small cleanups for invalid member ref
1 parent 1499811 commit ce61dfe

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,17 +2147,17 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
21472147
// to replace the metatype with 'Self'
21482148
// error saying the lookup cannot be on a protocol metatype
21492149
Optional<InFlightDiagnostic> Diag;
2150-
auto baseObjTy = BaseType;
2150+
auto baseTy = BaseType;
21512151

2152-
if (auto metatypeTy = baseObjTy->getAs<AnyMetatypeType>()) {
2152+
if (auto metatypeTy = baseTy->getAs<AnyMetatypeType>()) {
21532153
auto instanceTy = metatypeTy->getInstanceType();
21542154

21552155
// This will only happen if we have an unresolved dot expression
21562156
// (.foo) where foo is a protocol member and the contextual type is
21572157
// an optional protocol metatype.
21582158
if (auto objectTy = instanceTy->getOptionalObjectType()) {
21592159
instanceTy = objectTy;
2160-
baseObjTy = MetatypeType::get(objectTy);
2160+
baseTy = MetatypeType::get(objectTy);
21612161
}
21622162

21632163
if (instanceTy->isExistentialType()) {
@@ -2175,8 +2175,8 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
21752175
instanceTy));
21762176
} else {
21772177
Diag.emplace(emitDiagnostic(
2178-
loc, diag::could_not_use_type_member_on_protocol_metatype,
2179-
baseObjTy, Name));
2178+
loc, diag::could_not_use_type_member_on_protocol_metatype, baseTy,
2179+
Name));
21802180
}
21812181

21822182
Diag->highlight(baseRange).highlight(getAnchor()->getSourceRange());
@@ -2200,8 +2200,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
22002200
// components, let's provide a tailored diagnostic and return because
22012201
// that is unsupported so there is no fix-it.
22022202
if (locator->isForKeyPathComponent()) {
2203-
InvalidStaticMemberRefInKeyPath failure(expr, getConstraintSystem(),
2204-
member, locator);
2203+
InvalidStaticMemberRefInKeyPath failure(expr, cs, member, locator);
22052204
return failure.diagnoseAsError();
22062205
}
22072206

@@ -2210,13 +2209,13 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
22102209
loc, diag::could_not_use_enum_element_on_instance, Name));
22112210
} else {
22122211
Diag.emplace(emitDiagnostic(
2213-
loc, diag::could_not_use_type_member_on_instance, baseObjTy, Name));
2212+
loc, diag::could_not_use_type_member_on_instance, baseTy, Name));
22142213
}
22152214

22162215
Diag->highlight(getAnchor()->getSourceRange());
22172216

22182217
if (Name.isSimpleName(DeclBaseName::createConstructor()) &&
2219-
!baseObjTy->is<AnyMetatypeType>()) {
2218+
!baseTy->is<AnyMetatypeType>()) {
22202219
if (auto ctorRef = dyn_cast<UnresolvedDotExpr>(getRawAnchor())) {
22212220
SourceRange fixItRng = ctorRef->getNameLoc().getSourceRange();
22222221
Diag->fixItInsert(fixItRng.Start, "type(of: ");
@@ -2234,7 +2233,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
22342233

22352234
// Try to provide a fix-it that only contains a '.'
22362235
if (contextualType) {
2237-
if (baseObjTy->isEqual(contextualType)) {
2236+
if (baseTy->isEqual(contextualType)) {
22382237
Diag->fixItInsert(loc, ".");
22392238
return true;
22402239
}
@@ -2264,7 +2263,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
22642263
// since the type can be inferred
22652264
Type secondArgType =
22662265
lastCS->getType(binaryExpr->getArg()->getElement(1));
2267-
if (secondArgType->isEqual(baseObjTy)) {
2266+
if (secondArgType->isEqual(baseTy)) {
22682267
Diag->fixItInsert(loc, ".");
22692268
return true;
22702269
}

0 commit comments

Comments
 (0)