[Diagnostics] Diagnose keypath subscript components with missing Hashable conformances

This commit is contained in:
Pavel Yaskevich
2019-04-02 11:49:01 -07:00
parent c982706f0d
commit c3460f825d
3 changed files with 45 additions and 1 deletions

View File

@@ -2398,3 +2398,15 @@ bool InaccessibleMemberFailure::diagnoseAsError() {
emitDiagnostic(Member, diag::decl_declared_here, Member->getFullName());
return true;
}
bool KeyPathSubscriptIndexHashableFailure::diagnoseAsError() {
auto *anchor = cast<KeyPathExpr>(getRawAnchor());
auto path = getLocator()->getPath();
const auto &componentIndex = path.back().getValue();
auto *indexExpr = anchor->getComponents()[componentIndex].getIndexExpr();
emitDiagnostic(indexExpr->getLoc(),
diag::expr_keypath_subscript_index_not_hashable,
resolveType(NonConformingType));
return true;
}