mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Diagnose method arg captures that are not Hashable/Equatable.
This commit is contained in:
@@ -6347,7 +6347,8 @@ bool AnyObjectKeyPathRootFailure::diagnoseAsError() {
|
||||
SourceLoc KeyPathSubscriptIndexHashableFailure::getLoc() const {
|
||||
auto *locator = getLocator();
|
||||
|
||||
if (locator->isKeyPathSubscriptComponent()) {
|
||||
if (locator->isKeyPathSubscriptComponent() ||
|
||||
locator->isKeyPathMemberComponent()) {
|
||||
auto *KPE = castToExpr<KeyPathExpr>(getAnchor());
|
||||
if (auto kpElt = locator->findFirst<LocatorPathElt::KeyPathComponent>())
|
||||
return KPE->getComponents()[kpElt->getIndex()].getLoc();
|
||||
@@ -6357,7 +6358,9 @@ SourceLoc KeyPathSubscriptIndexHashableFailure::getLoc() const {
|
||||
}
|
||||
|
||||
bool KeyPathSubscriptIndexHashableFailure::diagnoseAsError() {
|
||||
emitDiagnostic(diag::expr_keypath_subscript_index_not_hashable,
|
||||
auto *locator = getLocator();
|
||||
emitDiagnostic(diag::expr_keypath_arg_or_index_not_hashable,
|
||||
!locator->isKeyPathMemberComponent(),
|
||||
resolveType(NonConformingType));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user