Skip to content

Commit 0269049

Browse files
committed
[Index] Fast path for getting value member
Avoid solving constraint system if there's only one viable overload. This should also avoids a crash we are seeing in 'candidates.size() == 1' branch in the constraint system. rdar://problem/64636688
1 parent 7d6abb8 commit 0269049

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Sema/CSGen.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4409,6 +4409,13 @@ swift::resolveValueMember(DeclContext &DC, Type BaseTy, DeclName Name) {
44094409
if (LookupResult.ViableCandidates.empty())
44104410
return Result;
44114411

4412+
// If there's only one viable member, that is the best one.
4413+
if (LookupResult.ViableCandidates.size() == 1) {
4414+
Result.Impl->BestIdx = Result.Impl->AllDecls.size();
4415+
Result.Impl->AllDecls.push_back(LookupResult.ViableCandidates[0].getDecl());
4416+
return Result;
4417+
}
4418+
44124419
// Try to figure out the best overload.
44134420
ConstraintLocator *Locator = CS.getConstraintLocator({});
44144421
TypeVariableType *TV = CS.createTypeVariable(Locator,

0 commit comments

Comments
 (0)