Skip to content

Commit 8b33cd0

Browse files
committed
[ConstraintSystem] Include argument labels into member name for AnyObject lookup
If we're referencing AnyObject and we have argument labels, put the argument labels into the name: we don't want to look for anything else, because the cost of the general search is so high.
1 parent b5cd400 commit 8b33cd0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4187,6 +4187,20 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
41874187
if (!instanceTy->mayHaveMembers())
41884188
return result;
41894189

4190+
// If we have a simple name, determine whether there are argument
4191+
// labels we can use to restrict the set of lookup results.
4192+
if (baseObjTy->isAnyObject() && memberName.isSimpleName()) {
4193+
// If we're referencing AnyObject and we have argument labels, put
4194+
// the argument labels into the name: we don't want to look for
4195+
// anything else, because the cost of the general search is so
4196+
// high.
4197+
if (auto argumentLabels =
4198+
getArgumentLabels(*this, ConstraintLocatorBuilder(memberLocator))) {
4199+
memberName = DeclName(TC.Context, memberName.getBaseName(),
4200+
argumentLabels->Labels);
4201+
}
4202+
}
4203+
41904204
// Look for members within the base.
41914205
LookupResult &lookup = lookupMember(instanceTy, memberName);
41924206

0 commit comments

Comments
 (0)