@@ -6060,20 +6060,33 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
6060
6060
6061
6061
auto locator = getConstraintLocator (locatorB);
6062
6062
6063
- // If this is an unresolved member ref e.g. `.foo` and its contextual base
6064
- // type has been determined to be a "hole", let's mark the resulting member
6065
- // type as a potential hole and continue solving.
6066
- if (shouldAttemptFixes () && kind == ConstraintKind::UnresolvedValueMember &&
6067
- baseObjTy->getMetatypeInstanceType ()->isHole ()) {
6068
- auto *fix =
6069
- SpecifyBaseTypeForContextualMember::create (*this , member, locator);
6070
- if (recordFix (fix))
6071
- return SolutionKind::Error;
6063
+ // If the base type of this member lookup is a "hole" there is no
6064
+ // reason to perform a lookup because it wouldn't return any results.
6065
+ if (shouldAttemptFixes ()) {
6066
+ auto markMemberTypeAsPotentialHole = [&](Type memberTy) {
6067
+ if (auto *typeVar = memberTy->getAs <TypeVariableType>())
6068
+ recordPotentialHole (typeVar);
6069
+ };
6072
6070
6073
- if (auto *typeVar = memberTy->getAs <TypeVariableType>())
6074
- recordPotentialHole (typeVar);
6071
+ // If this is an unresolved member ref e.g. `.foo` and its contextual base
6072
+ // type has been determined to be a "hole", let's mark the resulting member
6073
+ // type as a potential hole and continue solving.
6074
+ if (kind == ConstraintKind::UnresolvedValueMember &&
6075
+ baseObjTy->getMetatypeInstanceType ()->isHole ()) {
6076
+ auto *fix =
6077
+ SpecifyBaseTypeForContextualMember::create (*this , member, locator);
6078
+ if (recordFix (fix))
6079
+ return SolutionKind::Error;
6075
6080
6076
- return SolutionKind::Solved;
6081
+ markMemberTypeAsPotentialHole (memberTy);
6082
+ return SolutionKind::Solved;
6083
+ } else if (kind == ConstraintKind::ValueMember && baseObjTy->isHole ()) {
6084
+ // If base type is a "hole" there is no reason to record any
6085
+ // more "member not found" fixes for chained member references.
6086
+ increaseScore (SK_Fix);
6087
+ markMemberTypeAsPotentialHole (memberTy);
6088
+ return SolutionKind::Solved;
6089
+ }
6077
6090
}
6078
6091
6079
6092
MemberLookupResult result =
@@ -6345,15 +6358,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
6345
6358
// fake its presence based on use, that makes it possible to diagnose
6346
6359
// problems related to member lookup more precisely.
6347
6360
6348
- // If base type is a "hole" there is no reason to record any
6349
- // more "member not found" fixes for chained member references.
6350
- if (baseTy->isHole ()) {
6351
- increaseScore (SK_Fix);
6352
- if (auto *memberTypeVar = memberTy->getAs <TypeVariableType>())
6353
- recordPotentialHole (memberTypeVar);
6354
- return SolutionKind::Solved;
6355
- }
6356
-
6357
6361
return fixMissingMember (origBaseTy, memberTy, locator);
6358
6362
}
6359
6363
return SolutionKind::Error;
0 commit comments