[Runtime] Fix debugDescription of .self keypaths.

AnyKeyPath's debugDescription assumes there's always at least one component, but `\Type.self` produces an empty keypath. Special-case the empty case to display a `.self` component.

rdar://103237845
This commit is contained in:
Mike Ash
2022-12-12 14:34:22 -05:00
parent c914579e76
commit f440432891
2 changed files with 4 additions and 1 deletions

View File

@@ -3934,7 +3934,8 @@ extension AnyKeyPath: CustomDebugStringConvertible {
return withBuffer {
var buffer = $0
if buffer.data.isEmpty {
_internalInvariantFailure("key path has no components")
description.append(".self")
return description
}
var valueType: Any.Type = Self.rootType
while true {