Skip to content

Commit abc96ce

Browse files
committed
[StdLib] Handle nil property descriptors.
1 parent 93107cf commit abc96ce

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,11 +3119,18 @@ internal func _walkKeyPathPattern<W: KeyPathPatternVisitor>(
31193119
as: Int32.self)
31203120
let descriptor =
31213121
_resolveRelativeIndirectableAddress(descriptorBase, descriptorOffset)
3122-
let descriptorHeader =
3123-
descriptor.load(as: RawKeyPathComponent.Header.self)
3124-
if descriptorHeader.isTrivialPropertyDescriptor {
3125-
// If the descriptor is trivial, then use the local candidate.
3126-
// Skip the external generic parameter accessors to get to it.
3122+
let descriptorHeader: RawKeyPathComponent.Header
3123+
if descriptor != UnsafeRawPointer(bitPattern: 0) {
3124+
descriptorHeader = descriptor.load(as: RawKeyPathComponent.Header.self)
3125+
if descriptorHeader.isTrivialPropertyDescriptor {
3126+
// If the descriptor is trivial, then use the local candidate.
3127+
// Skip the external generic parameter accessors to get to it.
3128+
_ = _pop(from: &buffer, as: Int32.self, count: genericParamCount)
3129+
continue
3130+
}
3131+
} else {
3132+
// If the external property descriptor is nil, skip it to access
3133+
// the local candidate header.
31273134
_ = _pop(from: &buffer, as: Int32.self, count: genericParamCount)
31283135
continue
31293136
}

0 commit comments

Comments
 (0)