Skip to content

Commit 3b23ced

Browse files
committed
Clarify some comments
1 parent fea5309 commit 3b23ced

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stdlib/public/runtime/DynamicCast.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,11 +1724,11 @@ tryCastToExistentialMetatype(
17241724

17251725
// A layer of functions that evaluate the source and/or destination types
17261726
// in order to invoke a tailored casting operation above.
1727-
1727+
//
17281728
// This layer also deals with general issues of unwrapping box types
17291729
// and invoking bridging conversions defined via the _ObjectiveCBridgeable
17301730
// protocol.
1731-
1731+
//
17321732
// Most of the caster functions above should be fairly simple:
17331733
// * They should deal with a single target type,
17341734
// * They should assume the source is fully unwrapped,
@@ -1942,6 +1942,11 @@ tryCast(
19421942
//
19431943
// 4. Try recursively unwrapping Optionals. First try jointly unwrapping
19441944
// both source and destination, then just destination, then just source.
1945+
// Note that if both are optional, we try all three of these!
1946+
// For example, consider casting an Optional<T> to
1947+
// Optional<CustomDebugStringConvertible>. If T conforms, we need to
1948+
// unwrap both. But if it doesn't, we unwrap just the destination
1949+
// in order to cast Optional<T> to the protocol directly.
19451950
//
19461951
if (destKind == MetadataKind::Optional) {
19471952
if (srcKind == MetadataKind::Optional) {

0 commit comments

Comments
 (0)