Skip to content

Commit 374a10c

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.
1 parent 1fa3846 commit 374a10c

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
@@ -4232,13 +4232,13 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
42324232
DeclName memberName, const OverloadChoice &choice,
42334233
ConstraintLocator *locator,
42344234
Optional<MemberLookupResult::UnviableReason> reason = None) {
4235-
if (!choice.isDecl())
4236-
return nullptr;
4237-
4238-
auto *decl = choice.getDecl();
4239-
if (auto *CD = dyn_cast<ConstructorDecl>(decl)) {
4240-
if (auto *fix = validateInitializerRef(cs, CD, locator))
4241-
return fix;
4235+
// Not all of the choices handled here are going
4236+
// to refer to a declaration.
4237+
if (choice.isDecl()) {
4238+
if (auto *CD = dyn_cast<ConstructorDecl>(choice.getDecl())) {
4239+
if (auto *fix = validateInitializerRef(cs, CD, locator))
4240+
return fix;
4241+
}
42424242
}
42434243

42444244
if (reason) {
@@ -4248,7 +4248,8 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
42484248
return AllowTypeOrInstanceMember::create(cs, baseTy, memberName, locator);
42494249

42504250
case MemberLookupResult::UR_Inaccessible:
4251-
return AllowInaccessibleMember::create(cs, decl, locator);
4251+
assert(choice.isDecl());
4252+
return AllowInaccessibleMember::create(cs, choice.getDecl(), locator);
42524253

42534254
case MemberLookupResult::UR_MutatingMemberOnRValue:
42544255
case MemberLookupResult::UR_MutatingGetterOnRValue:

0 commit comments

Comments
 (0)