@@ -1121,7 +1121,7 @@ internal enum KeyPathComputedIDResolution {
11211121
11221122@_unavailableInEmbedded
11231123internal struct ComputedArgumentSize {
1124- let value : UInt
1124+ var value : UInt
11251125
11261126 static var sizeMask : UInt {
11271127#if _pointerBitWidth(_64)
@@ -1191,7 +1191,8 @@ internal struct ComputedArgumentSize {
11911191 }
11921192
11931193 set {
1194- let reduced = newValue / MemoryLayout< Int> . size
1194+ let new = UInt ( truncatingIfNeeded: newValue)
1195+ let reduced = new / UInt( truncatingIfNeeded: MemoryLayout< Int> . size)
11951196 let shift = reduced &<< Self . paddingShift
11961197 value &= ~ Self. paddingMask
11971198 value |= shift
@@ -1230,8 +1231,9 @@ internal struct ComputedArgumentSize {
12301231 // Nop on 64 bit.
12311232 return
12321233#elseif _pointerBitWidth(_32)
1233- let reduced = newValue == 16 ? 1 : 0
1234+ let reduced : UInt = newValue == 16 ? 1 : 0
12341235 let shift = reduced &<< Self . alignmentShift
1236+ value &= ~ ( 1 &<< Self . alignmentShift)
12351237 value |= shift
12361238#else
12371239#error("Unsupported platform")
@@ -1936,8 +1938,8 @@ internal struct RawKeyPathComponent {
19361938 )
19371939
19381940 // Push the buffer past the padding.
1939- unsafe argumentDest += padding
1940- componentSize += padding
1941+ unsafe argumentDest += newArgumentSize . padding
1942+ componentSize += newArgumentSize . padding
19411943 }
19421944 }
19431945
@@ -3718,7 +3720,7 @@ internal struct GetKeyPathClassAndInstanceSizeFromPattern
37183720 }
37193721
37203722 // Handle local arguments.
3721- if let arguments = arguments {
3723+ if let arguments = unsafe arguments {
37223724 // Argument size and witnesses ptr.
37233725 unsafe size &+= MemoryLayout < Int > . size &* 2
37243726
@@ -3734,23 +3736,23 @@ internal struct GetKeyPathClassAndInstanceSizeFromPattern
37343736 // We were misaligned, add the padding to the total size of the keypath
37353737 // buffer.
37363738 let typeAlign = typeAlignMask &+ 1
3737- unsafe size &+= typeAlign &- misalign
3739+ unsafe size &+= typeAlign &- misaligned
37383740 }
37393741
37403742 unsafe size &+= typeSize
37413743 unsafe roundUpToPointerAlignment( )
37423744 }
37433745
37443746 // Handle external arguments.
3745- if let externalArgs = externalArgs {
3747+ if let externalArgs = unsafe externalArgs {
37463748 // Argument size and witnesses ptr if we didn't have local arguments.
3747- if arguments == nil {
3749+ if unsafe arguments == nil {
37483750 unsafe size &+= MemoryLayout < Int > . size &* 2
37493751 }
37503752
37513753 // We also need to store the size of the local arguments so we can
37523754 // find the external component arguments.
3753- if arguments != nil {
3755+ if unsafe arguments != nil {
37543756 unsafe size &+= RawKeyPathComponent . Header. externalWithArgumentsExtraSize
37553757 }
37563758
@@ -4100,13 +4102,13 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
41004102 }
41014103
41024104 let ( typeSize, typeAlignMask) = unsafe arguments. getLayout ( patternArgs)
4103- var argumentSize = UInt ( truncatingIfNeeded : typeSize)
4105+ var argumentSize = typeSize
41044106
41054107 // If an external property descriptor also has arguments, they'll be
41064108 // added to the end with pointer alignment.
41074109 if let externalArgs = unsafe externalArgs {
4108- argumentSize = MemoryLayout< Int> . _roundingUpToAlignment( totalSize )
4109- argumentSize += UInt ( truncatingIfNeeded : MemoryLayout < Int > . size * externalArgs. count)
4110+ argumentSize = MemoryLayout< Int> . _roundingUpToAlignment( argumentSize )
4111+ argumentSize += MemoryLayout < Int > . size * externalArgs. count
41104112 }
41114113
41124114 // The argument total size contains the padding and alignment bits
0 commit comments