diff --git a/stdlib/public/core/KeyPath.swift b/stdlib/public/core/KeyPath.swift index d8cde37e9635b..af02640bdb07d 100644 --- a/stdlib/public/core/KeyPath.swift +++ b/stdlib/public/core/KeyPath.swift @@ -2507,7 +2507,7 @@ internal enum KeyPathPatternStoredOffset { case inline(UInt32) case outOfLine(UInt32) case unresolvedFieldOffset(UInt32) - case unresolvedIndirectOffset(UnsafePointer) + case unresolvedIndirectOffset(UnsafePointer) } internal struct KeyPathPatternComputedArguments { var getLayout: KeyPathComputedArgumentLayoutFn @@ -2602,7 +2602,7 @@ internal func _walkKeyPathPattern( as: Int32.self) let ptr = _resolveRelativeIndirectableAddress(base, relativeOffset) offset = .unresolvedIndirectOffset( - ptr.assumingMemoryBound(to: UInt32.self)) + ptr.assumingMemoryBound(to: UInt.self)) default: offset = .inline(header.storedOffsetPayload) } @@ -3151,7 +3151,8 @@ internal struct InstantiateKeyPathBuffer : KeyPathPatternVisitor { case .unresolvedIndirectOffset(let pointerToOffset): // Look up offset in the indirectly-referenced variable we have a // pointer. - let offset = UInt32(pointerToOffset.pointee) + assert(pointerToOffset.pointee <= UInt32.max) + let offset = UInt32(truncatingIfNeeded: pointerToOffset.pointee) let header = RawKeyPathComponent.Header(storedWithOutOfLineOffset: kind, mutable: mutable) pushDest(header)