@@ -238,7 +238,7 @@ internal struct BinaryDecoder: Decoder {
238238 if bodyBytes % itemSize != 0 || itemCount > UInt64 ( Int . max) {
239239 throw BinaryDecodingError . truncated
240240 }
241- value. reserveCapacity ( value. count + Int( extendingOrTruncating : itemCount) )
241+ value. reserveCapacity ( value. count + Int( truncatingIfNeeded : itemCount) )
242242 for _ in 1 ... itemCount {
243243 value. append ( try decodeFloat ( ) )
244244 }
@@ -279,7 +279,7 @@ internal struct BinaryDecoder: Decoder {
279279 if bodyBytes % itemSize != 0 || itemCount > UInt64 ( Int . max) {
280280 throw BinaryDecodingError . truncated
281281 }
282- value. reserveCapacity ( value. count + Int( extendingOrTruncating : itemCount) )
282+ value. reserveCapacity ( value. count + Int( truncatingIfNeeded : itemCount) )
283283 for _ in 1 ... itemCount {
284284 let i = try decodeDouble ( )
285285 value. append ( i)
@@ -296,7 +296,7 @@ internal struct BinaryDecoder: Decoder {
296296 return
297297 }
298298 let varint = try decodeVarint ( )
299- value = Int32 ( extendingOrTruncating : varint)
299+ value = Int32 ( truncatingIfNeeded : varint)
300300 consumed = true
301301 }
302302
@@ -305,15 +305,15 @@ internal struct BinaryDecoder: Decoder {
305305 return
306306 }
307307 let varint = try decodeVarint ( )
308- value = Int32 ( extendingOrTruncating : varint)
308+ value = Int32 ( truncatingIfNeeded : varint)
309309 consumed = true
310310 }
311311
312312 internal mutating func decodeRepeatedInt32Field( value: inout [ Int32 ] ) throws {
313313 switch fieldWireFormat {
314314 case WireFormat . varint:
315315 let varint = try decodeVarint ( )
316- value. append ( Int32 ( extendingOrTruncating : varint) )
316+ value. append ( Int32 ( truncatingIfNeeded : varint) )
317317 consumed = true
318318 case WireFormat . lengthDelimited:
319319 var n : Int = 0
@@ -323,7 +323,7 @@ internal struct BinaryDecoder: Decoder {
323323 var decoder = BinaryDecoder ( forReadingFrom: p, count: n, parent: self )
324324 while !decoder. complete {
325325 let varint = try decoder. decodeVarint ( )
326- value. append ( Int32 ( extendingOrTruncating : varint) )
326+ value. append ( Int32 ( truncatingIfNeeded : varint) )
327327 }
328328 consumed = true
329329 default :
@@ -376,7 +376,7 @@ internal struct BinaryDecoder: Decoder {
376376 return
377377 }
378378 let varint = try decodeVarint ( )
379- value = UInt32 ( extendingOrTruncating : varint)
379+ value = UInt32 ( truncatingIfNeeded : varint)
380380 consumed = true
381381 }
382382
@@ -385,15 +385,15 @@ internal struct BinaryDecoder: Decoder {
385385 return
386386 }
387387 let varint = try decodeVarint ( )
388- value = UInt32 ( extendingOrTruncating : varint)
388+ value = UInt32 ( truncatingIfNeeded : varint)
389389 consumed = true
390390 }
391391
392392 internal mutating func decodeRepeatedUInt32Field( value: inout [ UInt32 ] ) throws {
393393 switch fieldWireFormat {
394394 case WireFormat . varint:
395395 let varint = try decodeVarint ( )
396- value. append ( UInt32 ( extendingOrTruncating : varint) )
396+ value. append ( UInt32 ( truncatingIfNeeded : varint) )
397397 consumed = true
398398 case WireFormat . lengthDelimited:
399399 var n : Int = 0
@@ -403,7 +403,7 @@ internal struct BinaryDecoder: Decoder {
403403 var decoder = BinaryDecoder ( forReadingFrom: p, count: n, parent: self )
404404 while !decoder. complete {
405405 let t = try decoder. decodeVarint ( )
406- value. append ( UInt32 ( extendingOrTruncating : t) )
406+ value. append ( UInt32 ( truncatingIfNeeded : t) )
407407 }
408408 consumed = true
409409 default :
@@ -454,7 +454,7 @@ internal struct BinaryDecoder: Decoder {
454454 return
455455 }
456456 let varint = try decodeVarint ( )
457- let t = UInt32 ( extendingOrTruncating : varint)
457+ let t = UInt32 ( truncatingIfNeeded : varint)
458458 value = ZigZag . decoded ( t)
459459 consumed = true
460460 }
@@ -464,7 +464,7 @@ internal struct BinaryDecoder: Decoder {
464464 return
465465 }
466466 let varint = try decodeVarint ( )
467- let t = UInt32 ( extendingOrTruncating : varint)
467+ let t = UInt32 ( truncatingIfNeeded : varint)
468468 value = ZigZag . decoded ( t)
469469 consumed = true
470470 }
@@ -473,7 +473,7 @@ internal struct BinaryDecoder: Decoder {
473473 switch fieldWireFormat {
474474 case WireFormat . varint:
475475 let varint = try decodeVarint ( )
476- let t = UInt32 ( extendingOrTruncating : varint)
476+ let t = UInt32 ( truncatingIfNeeded : varint)
477477 value. append ( ZigZag . decoded ( t) )
478478 consumed = true
479479 case WireFormat . lengthDelimited:
@@ -484,7 +484,7 @@ internal struct BinaryDecoder: Decoder {
484484 var decoder = BinaryDecoder ( forReadingFrom: p, count: n, parent: self )
485485 while !decoder. complete {
486486 let varint = try decoder. decodeVarint ( )
487- let t = UInt32 ( extendingOrTruncating : varint)
487+ let t = UInt32 ( truncatingIfNeeded : varint)
488488 value. append ( ZigZag . decoded ( t) )
489489 }
490490 consumed = true
@@ -824,7 +824,7 @@ internal struct BinaryDecoder: Decoder {
824824 return
825825 }
826826 let varint = try decodeVarint ( )
827- if let v = E ( rawValue: Int ( Int32 ( extendingOrTruncating : varint) ) ) {
827+ if let v = E ( rawValue: Int ( Int32 ( truncatingIfNeeded : varint) ) ) {
828828 value = v
829829 consumed = true
830830 }
@@ -835,7 +835,7 @@ internal struct BinaryDecoder: Decoder {
835835 return
836836 }
837837 let varint = try decodeVarint ( )
838- if let v = E ( rawValue: Int ( Int32 ( extendingOrTruncating : varint) ) ) {
838+ if let v = E ( rawValue: Int ( Int32 ( truncatingIfNeeded : varint) ) ) {
839839 value = v
840840 consumed = true
841841 }
@@ -845,7 +845,7 @@ internal struct BinaryDecoder: Decoder {
845845 switch fieldWireFormat {
846846 case WireFormat . varint:
847847 let varint = try decodeVarint ( )
848- if let v = E ( rawValue: Int ( Int32 ( extendingOrTruncating : varint) ) ) {
848+ if let v = E ( rawValue: Int ( Int32 ( truncatingIfNeeded : varint) ) ) {
849849 value. append ( v)
850850 consumed = true
851851 }
@@ -858,7 +858,7 @@ internal struct BinaryDecoder: Decoder {
858858 var subdecoder = BinaryDecoder ( forReadingFrom: p, count: n, parent: self )
859859 while !subdecoder. complete {
860860 let u64 = try subdecoder. decodeVarint ( )
861- let i32 = Int32 ( extendingOrTruncating : u64)
861+ let i32 = Int32 ( truncatingIfNeeded : u64)
862862 if let v = E ( rawValue: Int ( i32) ) {
863863 value. append ( v)
864864 } else if !options. discardUnknownFields {
@@ -1417,7 +1417,7 @@ internal struct BinaryDecoder: Decoder {
14171417 }
14181418 let t = try decodeVarint ( )
14191419 if t < UInt64 ( UInt32 . max) {
1420- guard let tag = FieldTag ( rawValue: UInt32 ( extendingOrTruncating : t) ) else {
1420+ guard let tag = FieldTag ( rawValue: UInt32 ( truncatingIfNeeded : t) ) else {
14211421 throw BinaryDecodingError . malformedProtobuf
14221422 }
14231423 fieldWireFormat = tag. wireFormat
0 commit comments