Skip to content

Commit 63330f9

Browse files
[Sema] Do not emit warning about conditional cast bridge when from type is optional
1 parent dc60996 commit 63330f9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6663,6 +6663,13 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
66636663
return fix;
66646664
}
66656665
if (extraOptionals > 0) {
6666+
// Conditional cast in this case can be an attempt to just unwrap a nil
6667+
// value.
6668+
if (isExpr<ConditionalCheckedCastExpr>(anchor) &&
6669+
castKind == CheckedCastKind::BridgingCoercion) {
6670+
return nullptr;
6671+
}
6672+
66666673
return AllowCheckedCastCoercibleOptionalType::create(
66676674
cs, origFromType, origToType, castKind,
66686675
cs.getConstraintLocator(locator));

0 commit comments

Comments
 (0)