Skip to content

Commit a57140e

Browse files
committed
[StdLib] Handle nil property descriptors.
1 parent 9cf1ca1 commit a57140e

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
@@ -3116,11 +3116,18 @@ internal func _walkKeyPathPattern<W: KeyPathPatternVisitor>(
31163116
as: Int32.self)
31173117
let descriptor =
31183118
_resolveRelativeIndirectableAddress(descriptorBase, descriptorOffset)
3119-
let descriptorHeader =
3120-
descriptor.load(as: RawKeyPathComponent.Header.self)
3121-
if descriptorHeader.isTrivialPropertyDescriptor {
3122-
// If the descriptor is trivial, then use the local candidate.
3123-
// Skip the external generic parameter accessors to get to it.
3119+
let descriptorHeader: RawKeyPathComponent.Header
3120+
if descriptor != UnsafeRawPointer(bitPattern: 0) {
3121+
descriptorHeader = descriptor.load(as: RawKeyPathComponent.Header.self)
3122+
if descriptorHeader.isTrivialPropertyDescriptor {
3123+
// If the descriptor is trivial, then use the local candidate.
3124+
// Skip the external generic parameter accessors to get to it.
3125+
_ = _pop(from: &buffer, as: Int32.self, count: genericParamCount)
3126+
continue
3127+
}
3128+
} else {
3129+
// If the external property descriptor is nil, skip it to access
3130+
// the local candidate header.
31243131
_ = _pop(from: &buffer, as: Int32.self, count: genericParamCount)
31253132
continue
31263133
}

0 commit comments

Comments
 (0)