Skip to content

Commit 83744d9

Browse files
committed
[Diagnostics] Use ´isa instead of dyn_cast` because array/dictionary expr in unused
1 parent 07865c7 commit 83744d9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,11 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
671671
}
672672

673673
case ConstraintLocator::TupleElement: {
674-
if (auto *array = dyn_cast<ArrayExpr>(getRawAnchor()))
675-
diagnostic = getDiagnosticFor(CTP_ArrayElement);
674+
auto *anchor = getRawAnchor();
676675

677-
if (auto *dict = dyn_cast<DictionaryExpr>(getRawAnchor())) {
676+
if (isa<ArrayExpr>(anchor)) {
677+
diagnostic = getDiagnosticFor(CTP_ArrayElement);
678+
} else if (isa<DictionaryExpr>(anchor)) {
678679
auto eltLoc = last.castTo<LocatorPathElt::TupleElement>();
679680
diagnostic = getDiagnosticFor(
680681
eltLoc.getIndex() == 0 ? CTP_DictionaryKey : CTP_DictionaryValue);

0 commit comments

Comments
 (0)