Skip to content

Commit 31808e8

Browse files
[TypeChecker] Adjusting comments
1 parent 026f697 commit 31808e8

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,8 +3534,9 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType,
35343534
(toType->isAnyObject() || fromType->isAnyObject()))
35353535
return CheckedCastKind::ValueCast;
35363536

3537-
// A cast from an existential type to a concrete type does not succeed. For
3538-
// example:
3537+
// If we have a cast from an existential type to a concrete type that we
3538+
// statically know doesn't conform to the protocol, mark the cast as always
3539+
// failing. For example:
35393540
//
35403541
// struct S {}
35413542
// enum FooError: Error { case bar }
@@ -3548,12 +3549,8 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType,
35483549
// }
35493550
// }
35503551
//
3551-
// But we check for conformance and possible dynamic conformances in which
3552-
// case we cannot fail because it is impossible to know then statically.
35533552
if (auto *protocolDecl =
35543553
dyn_cast_or_null<ProtocolDecl>(fromType->getAnyNominal())) {
3555-
// Checking for possible dynamic conformances because we cannot fail
3556-
// in those cases.
35573554
if (!couldDynamicallyConformToProtocol(toType, protocolDecl, dc)) {
35583555
return failed();
35593556
}

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4473,7 +4473,7 @@ TypeChecker::conformsToProtocol(Type T, ProtocolDecl *Proto, DeclContext *DC,
44734473
bool
44744474
TypeChecker::couldDynamicallyConformToProtocol(Type type, ProtocolDecl *Proto,
44754475
DeclContext *DC) {
4476-
// An existential may have an concrete underlying type that protocol conformances
4476+
// An existential may have a concrete underlying type with protocol conformances
44774477
// we cannot know statically.
44784478
if (type->isExistentialType())
44794479
return true;

0 commit comments

Comments
 (0)