@@ -4203,9 +4203,9 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
4203
4203
break ;
4204
4204
}
4205
4205
4206
+ SmallVector<Constraint *, 4 > candidates;
4206
4207
// If we found viable candidates, then we're done!
4207
4208
if (!result.ViableCandidates .empty ()) {
4208
- llvm::SmallVector<Constraint *, 8 > candidates;
4209
4209
generateConstraints (
4210
4210
candidates, memberTy, result.ViableCandidates , useDC, locator,
4211
4211
result.getFavoredIndex (), /* requiresFix=*/ false ,
@@ -4222,11 +4222,30 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
4222
4222
generateConstraints (candidates, memberTy, outerAlternatives,
4223
4223
useDC, locator);
4224
4224
}
4225
+ }
4226
+
4227
+ if (!result.UnviableCandidates .empty ()) {
4228
+ SmallVector<OverloadChoice, 8 > choices;
4229
+ llvm::transform (
4230
+ result.UnviableCandidates , std::back_inserter (choices),
4231
+ [](const std::pair<OverloadChoice, MemberLookupResult::UnviableReason>
4232
+ &candidate) { return candidate.first ; });
4233
+
4234
+ // Generate constraints for unvailable choices if they have a fix,
4235
+ // and disable them by default, they'd get picked up in the "salvage" mode.
4236
+ generateConstraints (candidates, memberTy, choices, useDC, locator,
4237
+ /* favoredChoice=*/ None, /* requiresFix=*/ true ,
4238
+ [&](unsigned idx, const OverloadChoice &choice) {
4239
+ return fixMemberRef (
4240
+ *this , baseTy, member, choice, locator,
4241
+ result.UnviableCandidates [idx].second );
4242
+ });
4243
+ }
4225
4244
4245
+ if (!candidates.empty ()) {
4226
4246
addOverloadSet (candidates, locator);
4227
4247
return SolutionKind::Solved;
4228
4248
}
4229
-
4230
4249
4231
4250
// If the lookup found no hits at all (either viable or unviable), diagnose it
4232
4251
// as such and try to recover in various ways.
@@ -4238,30 +4257,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
4238
4257
if (!MissingMembers.insert (locator))
4239
4258
return SolutionKind::Error;
4240
4259
4241
- if (!result.UnviableCandidates .empty ()) {
4242
- SmallVector<OverloadChoice, 8 > choices;
4243
- llvm::transform (
4244
- result.UnviableCandidates , std::back_inserter (choices),
4245
- [](const std::pair<OverloadChoice, MemberLookupResult::UnviableReason>
4246
- &candidate) { return candidate.first ; });
4247
-
4248
- SmallVector<Constraint *, 4 > candidates;
4249
- generateConstraints (candidates, memberTy, choices, useDC, locator,
4250
- /* favoredChoice=*/ None, /* requiresFix=*/ true ,
4251
- [&](unsigned idx, const OverloadChoice &choice) {
4252
- return fixMemberRef (
4253
- *this , baseTy, member, choice, locator,
4254
- result.UnviableCandidates [idx].second );
4255
- });
4256
-
4257
- // If there are any viable "fixed" candidates, let's schedule
4258
- // them to be attempted.
4259
- if (!candidates.empty ()) {
4260
- addOverloadSet (candidates, locator);
4261
- return SolutionKind::Solved;
4262
- }
4263
- }
4264
-
4265
4260
if (baseObjTy->getOptionalObjectType ()) {
4266
4261
// If the base type was an optional, look through it.
4267
4262
0 commit comments