Skip to content

Commit 6c2b125

Browse files
committed
[CSDiagnostics] Tailor diagnostic for Copyable conformance mismatch in key path context
1 parent a8baec6 commit 6c2b125

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,15 @@ bool MissingConformanceFailure::diagnoseAsError() {
683683
}
684684
}
685685

686+
if (isExpr<KeyPathExpr>(anchor)) {
687+
if (auto *P = dyn_cast<ProtocolDecl>(protocolType->getAnyNominal())) {
688+
if (P->isSpecificProtocol(KnownProtocolKind::Copyable)) {
689+
emitDiagnostic(diag::expr_keypath_noncopyable_type, nonConformingType);
690+
return true;
691+
}
692+
}
693+
}
694+
686695
if (diagnoseAsAmbiguousOperatorRef())
687696
return true;
688697

0 commit comments

Comments
 (0)