[Diagnostics] Let invalid member ref carry member declaration instead of looking it up

All places where `invalid member ref` fix/diagnostic is used already
have a reference to the potential member choice declaration, which
diagnostic could take advantage of.
This commit is contained in:
Pavel Yaskevich
2019-05-21 11:49:00 -07:00
parent 48688241c3
commit 866e8f51fa
6 changed files with 44 additions and 59 deletions

View File

@@ -4530,8 +4530,12 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
if (reason) {
switch (*reason) {
case MemberLookupResult::UR_InstanceMemberOnType:
case MemberLookupResult::UR_TypeMemberOnInstance:
return AllowTypeOrInstanceMember::create(cs, baseTy, memberName, locator);
case MemberLookupResult::UR_TypeMemberOnInstance: {
return choice.isDecl()
? AllowTypeOrInstanceMember::create(
cs, baseTy, choice.getDecl(), memberName, locator)
: nullptr;
}
case MemberLookupResult::UR_Inaccessible:
assert(choice.isDecl());