@@ -2147,17 +2147,17 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
2147
2147
// to replace the metatype with 'Self'
2148
2148
// error saying the lookup cannot be on a protocol metatype
2149
2149
Optional<InFlightDiagnostic> Diag;
2150
- auto baseObjTy = BaseType;
2150
+ auto baseTy = BaseType;
2151
2151
2152
- if (auto metatypeTy = baseObjTy ->getAs <AnyMetatypeType>()) {
2152
+ if (auto metatypeTy = baseTy ->getAs <AnyMetatypeType>()) {
2153
2153
auto instanceTy = metatypeTy->getInstanceType ();
2154
2154
2155
2155
// This will only happen if we have an unresolved dot expression
2156
2156
// (.foo) where foo is a protocol member and the contextual type is
2157
2157
// an optional protocol metatype.
2158
2158
if (auto objectTy = instanceTy->getOptionalObjectType ()) {
2159
2159
instanceTy = objectTy;
2160
- baseObjTy = MetatypeType::get (objectTy);
2160
+ baseTy = MetatypeType::get (objectTy);
2161
2161
}
2162
2162
2163
2163
if (instanceTy->isExistentialType ()) {
@@ -2175,8 +2175,8 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
2175
2175
instanceTy));
2176
2176
} else {
2177
2177
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));
2180
2180
}
2181
2181
2182
2182
Diag->highlight (baseRange).highlight (getAnchor ()->getSourceRange ());
@@ -2200,8 +2200,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
2200
2200
// components, let's provide a tailored diagnostic and return because
2201
2201
// that is unsupported so there is no fix-it.
2202
2202
if (locator->isForKeyPathComponent ()) {
2203
- InvalidStaticMemberRefInKeyPath failure (expr, getConstraintSystem (),
2204
- member, locator);
2203
+ InvalidStaticMemberRefInKeyPath failure (expr, cs, member, locator);
2205
2204
return failure.diagnoseAsError ();
2206
2205
}
2207
2206
@@ -2210,13 +2209,13 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
2210
2209
loc, diag::could_not_use_enum_element_on_instance, Name));
2211
2210
} else {
2212
2211
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));
2214
2213
}
2215
2214
2216
2215
Diag->highlight (getAnchor ()->getSourceRange ());
2217
2216
2218
2217
if (Name.isSimpleName (DeclBaseName::createConstructor ()) &&
2219
- !baseObjTy ->is <AnyMetatypeType>()) {
2218
+ !baseTy ->is <AnyMetatypeType>()) {
2220
2219
if (auto ctorRef = dyn_cast<UnresolvedDotExpr>(getRawAnchor ())) {
2221
2220
SourceRange fixItRng = ctorRef->getNameLoc ().getSourceRange ();
2222
2221
Diag->fixItInsert (fixItRng.Start , " type(of: " );
@@ -2234,7 +2233,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
2234
2233
2235
2234
// Try to provide a fix-it that only contains a '.'
2236
2235
if (contextualType) {
2237
- if (baseObjTy ->isEqual (contextualType)) {
2236
+ if (baseTy ->isEqual (contextualType)) {
2238
2237
Diag->fixItInsert (loc, " ." );
2239
2238
return true ;
2240
2239
}
@@ -2264,7 +2263,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
2264
2263
// since the type can be inferred
2265
2264
Type secondArgType =
2266
2265
lastCS->getType (binaryExpr->getArg ()->getElement (1 ));
2267
- if (secondArgType->isEqual (baseObjTy )) {
2266
+ if (secondArgType->isEqual (baseTy )) {
2268
2267
Diag->fixItInsert (loc, " ." );
2269
2268
return true ;
2270
2269
}
0 commit comments