Skip to content

Commit eb1810c

Browse files
committed
[Typechecker] Simplify the non-final check when checking a cast from existential type to a concrete type
1 parent 3ce1156 commit eb1810c

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4304,15 +4304,7 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType,
43044304
// that conforms to the protocol.
43054305
if (fromExistential && !toExistential) {
43064306
if (auto NTD = toType->getAnyNominal()) {
4307-
bool shouldContinue = true;
4308-
4309-
// If we have a non-final class, then don't check
4310-
if (toType->is<ClassType>() && !NTD->isFinal()) {
4311-
shouldContinue = false;
4312-
}
4313-
4314-
// Otherwise, check the cast.
4315-
if (shouldContinue) {
4307+
if (!toType->is<ClassType>() || NTD->isFinal()) {
43164308
auto protocolDecl =
43174309
dyn_cast_or_null<ProtocolDecl>(fromType->getAnyNominal());
43184310
if (protocolDecl &&

0 commit comments

Comments
 (0)