Skip to content

Commit fd377dc

Browse files
committed
[CSSimplify] Fix unviable "instance member on metatype" choice
Adjust base type and reference kind so it looks as-if it is a correct reference when used by constraint system.
1 parent 8de1763 commit fd377dc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3753,8 +3753,15 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
37533753
if (decl->isInstanceMember()) {
37543754
if ((isa<FuncDecl>(decl) && !hasInstanceMethods) ||
37553755
(!isa<FuncDecl>(decl) && !hasInstanceMembers)) {
3756-
result.addUnviable(candidate,
3757-
MemberLookupResult::UR_InstanceMemberOnType);
3756+
// `AnyObject` has special semantics, so let's just let it be.
3757+
// Otherwise adjust base type and reference kind to make it
3758+
// look as if lookup was done on the instance, that helps
3759+
// with diagnostics.
3760+
auto choice = instanceTy->isAnyObject()
3761+
? candidate
3762+
: OverloadChoice(instanceTy, decl,
3763+
FunctionRefKind::SingleApply);
3764+
result.addUnviable(choice, MemberLookupResult::UR_InstanceMemberOnType);
37583765
return;
37593766
}
37603767

0 commit comments

Comments
 (0)