Skip to content

Commit 4cbf09e

Browse files
committed
[ConstraintSystem] Overload choice should not be required to refer to declaration to have a fix
We should be able to attach fixes to overload choices that don't refer to declarations e.g. keypath applications which refer to `AnyObject` is a base type. (cherry picked from commit 374a10c)
1 parent 9be7646 commit 4cbf09e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,13 +4259,13 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
42594259
DeclName memberName, const OverloadChoice &choice,
42604260
ConstraintLocator *locator,
42614261
Optional<MemberLookupResult::UnviableReason> reason = None) {
4262-
if (!choice.isDecl())
4263-
return nullptr;
4264-
4265-
auto *decl = choice.getDecl();
4266-
if (auto *CD = dyn_cast<ConstructorDecl>(decl)) {
4267-
if (auto *fix = validateInitializerRef(cs, CD, locator))
4268-
return fix;
4262+
// Not all of the choices handled here are going
4263+
// to refer to a declaration.
4264+
if (choice.isDecl()) {
4265+
if (auto *CD = dyn_cast<ConstructorDecl>(choice.getDecl())) {
4266+
if (auto *fix = validateInitializerRef(cs, CD, locator))
4267+
return fix;
4268+
}
42694269
}
42704270

42714271
if (reason) {
@@ -4275,7 +4275,8 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
42754275
return AllowTypeOrInstanceMember::create(cs, baseTy, memberName, locator);
42764276

42774277
case MemberLookupResult::UR_Inaccessible:
4278-
return AllowInaccessibleMember::create(cs, decl, locator);
4278+
assert(choice.isDecl());
4279+
return AllowInaccessibleMember::create(cs, choice.getDecl(), locator);
42794280

42804281
case MemberLookupResult::UR_MutatingMemberOnRValue:
42814282
case MemberLookupResult::UR_MutatingGetterOnRValue:

0 commit comments

Comments
 (0)