mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #24097 from xedin/diag-mutating-getter-in-keypath
[ConstraintSystem] Detect and diagnoses use of members with mutating getters in key path
This commit is contained in:
@@ -2453,9 +2453,8 @@ bool KeyPathSubscriptIndexHashableFailure::diagnoseAsError() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidStaticMemberRefInKeyPath::diagnoseAsError() {
|
||||
SourceLoc InvalidMemberRefInKeyPath::getLoc() const {
|
||||
auto *anchor = getRawAnchor();
|
||||
auto loc = anchor->getLoc();
|
||||
|
||||
if (auto *KPE = dyn_cast<KeyPathExpr>(anchor)) {
|
||||
auto *locator = getLocator();
|
||||
@@ -2465,9 +2464,18 @@ bool InvalidStaticMemberRefInKeyPath::diagnoseAsError() {
|
||||
});
|
||||
|
||||
assert(component != locator->getPath().end());
|
||||
loc = KPE->getComponents()[component->getValue()].getLoc();
|
||||
return KPE->getComponents()[component->getValue()].getLoc();
|
||||
}
|
||||
|
||||
emitDiagnostic(loc, diag::expr_keypath_static_member, Member->getBaseName());
|
||||
return anchor->getLoc();
|
||||
}
|
||||
|
||||
bool InvalidStaticMemberRefInKeyPath::diagnoseAsError() {
|
||||
emitDiagnostic(getLoc(), diag::expr_keypath_static_member, getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidMemberWithMutatingGetterInKeyPath::diagnoseAsError() {
|
||||
emitDiagnostic(getLoc(), diag::expr_keypath_mutating_getter, getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user