Skip to content

Commit 47d02db

Browse files
authored
Merge pull request #62528 from mikeash/self-keypath-debug-description
[Runtime] Fix debugDescription of .self keypaths.
2 parents 38dac1a + f440432 commit 47d02db

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3944,7 +3944,8 @@ extension AnyKeyPath: CustomDebugStringConvertible {
39443944
return withBuffer {
39453945
var buffer = $0
39463946
if buffer.data.isEmpty {
3947-
_internalInvariantFailure("key path has no components")
3947+
description.append(".self")
3948+
return description
39483949
}
39493950
var valueType: Any.Type = Self.rootType
39503951
while true {

test/Interpreter/keypath.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,5 @@ print(\Controller[int: 0, str: "", 0])
9393
print(\Controller.thirdLabel)
9494
// CHECK: {{\\Controller\.subscript\(\)|\\Controller\.<computed 0x.* \(Int\)>}}
9595
print(\Controller.[])
96+
// CHECK: \Controller.self
97+
print(\Controller.self)

0 commit comments

Comments
 (0)