Skip to content

Commit dc886eb

Browse files
committed
Sema: Move call to getRValueType inside of getBaseType
1 parent 147280a commit dc886eb

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ void FailureDiagnosis::diagnoseUnviableLookupResults(
757757
break;
758758

759759
case MemberLookupResult::UR_UnavailableInExistential: {
760-
InvalidMemberRefOnExistential failure(baseExpr, CS, instanceTy, memberName,
761-
CS.getConstraintLocator(E));
760+
InvalidMemberRefOnExistential failure(
761+
baseExpr, CS, instanceTy, memberName, CS.getConstraintLocator(E));
762762
failure.diagnoseAsError();
763763
return;
764764
}

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ bool InvalidMemberRefOnExistential::diagnoseAsError() {
19781978
}
19791979

19801980
emitDiagnostic(getAnchor()->getLoc(),
1981-
diag::could_not_use_member_on_existential, getBaseType()->getRValueType(),
1981+
diag::could_not_use_member_on_existential, getBaseType(),
19821982
getName())
19831983
.highlight(nameLoc.getSourceRange())
19841984
.highlight(baseExpr->getSourceRange());

lib/Sema/CSDiagnostics.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -765,13 +765,13 @@ class SubscriptMisuseFailure final : public FailureDiagnostic {
765765
class InvalidMemberRefFailure : public FailureDiagnostic {
766766
Type BaseType;
767767
DeclName Name;
768-
768+
769769
public:
770770
InvalidMemberRefFailure(Expr *root, ConstraintSystem &cs, Type baseType,
771771
DeclName memberName, ConstraintLocator *locator)
772-
: FailureDiagnostic(root, cs, locator),
773-
BaseType(baseType), Name(memberName) {}
774-
772+
: FailureDiagnostic(root, cs, locator), BaseType(baseType->getRValueType()),
773+
Name(memberName) {}
774+
775775
protected:
776776
Type getBaseType() const { return BaseType; }
777777
DeclName getName() const { return Name; }
@@ -815,9 +815,8 @@ class MissingMemberFailure final : public InvalidMemberRefFailure {
815815
/// ```
816816
class InvalidMemberRefOnExistential final : public InvalidMemberRefFailure {
817817
public:
818-
InvalidMemberRefOnExistential(Expr *root, ConstraintSystem &cs,
819-
Type baseType, DeclName memberName,
820-
ConstraintLocator *locator)
818+
InvalidMemberRefOnExistential(Expr *root, ConstraintSystem &cs, Type baseType,
819+
DeclName memberName, ConstraintLocator *locator)
821820
: InvalidMemberRefFailure(root, cs, baseType, memberName, locator) {}
822821

823822
bool diagnoseAsError() override;

lib/Sema/CSFix.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ DefineMemberBasedOnUse::create(ConstraintSystem &cs, Type baseType,
285285

286286
AllowMemberRefOnExistential *
287287
AllowMemberRefOnExistential::create(ConstraintSystem &cs, Type baseType,
288-
ValueDecl *member, DeclName memberName,
289-
ConstraintLocator *locator) {
288+
ValueDecl *member, DeclName memberName,
289+
ConstraintLocator *locator) {
290290
return new (cs.getAllocator())
291291
AllowMemberRefOnExistential(cs, baseType, memberName, member, locator);
292292
}

lib/Sema/CSFix.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ class AllowMemberRefOnExistential final : public ConstraintFix {
603603
DeclName Name;
604604

605605
AllowMemberRefOnExistential(ConstraintSystem &cs, Type baseType,
606-
DeclName memberName, ValueDecl *member,
607-
ConstraintLocator *locator)
606+
DeclName memberName, ValueDecl *member,
607+
ConstraintLocator *locator)
608608
: ConstraintFix(cs, FixKind::AllowMemberRefOnExistential, locator),
609609
BaseType(baseType), Name(memberName) {}
610610

@@ -618,9 +618,10 @@ class AllowMemberRefOnExistential final : public ConstraintFix {
618618

619619
bool diagnose(Expr *root, bool asNote = false) const override;
620620

621-
static AllowMemberRefOnExistential *create(ConstraintSystem &cs, Type baseType,
622-
ValueDecl *member, DeclName memberName,
623-
ConstraintLocator *locator);
621+
static AllowMemberRefOnExistential *create(ConstraintSystem &cs,
622+
Type baseType, ValueDecl *member,
623+
DeclName memberName,
624+
ConstraintLocator *locator);
624625
};
625626

626627
class AllowTypeOrInstanceMember final : public ConstraintFix {

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4531,8 +4531,8 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
45314531

45324532
case MemberLookupResult::UR_UnavailableInExistential: {
45334533
return choice.isDecl()
4534-
? AllowMemberRefOnExistential::create(cs, baseTy, choice.getDecl(),
4535-
memberName, locator)
4534+
? AllowMemberRefOnExistential::create(
4535+
cs, baseTy, choice.getDecl(), memberName, locator)
45364536
: nullptr;
45374537
}
45384538

0 commit comments

Comments
 (0)