Skip to content

Commit d768c75

Browse files
committed
NCGenerics: narrow use of custom diagnostics
In some cases we get a `ConstraintKind::SelfObjectOfProtocol` here. That's typically for an existential cast. In such a case, we actually get a better standard diagnostic than what MustBeCopyable can produce currently. So this change narrows things to what MustBeCopyable is better at diagnosing.
1 parent c3f9b6f commit d768c75

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8705,7 +8705,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
87058705
}
87068706

87078707
// If this is a failure to conform to Copyable, tailor the error message.
8708-
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
8708+
if (kind == ConstraintKind::ConformsTo &&
8709+
protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
87098710
auto *fix =
87108711
MustBeCopyable::create(*this,
87118712
type,

0 commit comments

Comments
 (0)