Skip to content

Commit 9a82435

Browse files
authored
Merge pull request apple#631 from tbkka/old-xcode-fixes
Xcode compatibility fixes...
2 parents a65b397 + 6828ba5 commit 9a82435

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

Sources/SwiftProtobuf/JSONDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ internal struct JSONDecoder: Decoder {
464464
value = nil
465465
return
466466
}
467-
value = try scanner.nextEnumValue()
467+
value = try scanner.nextEnumValue() as E
468468
}
469469

470470
mutating func decodeSingularEnumField<E: Enum>(value: inout E) throws

Sources/SwiftProtobuf/JSONScanner.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private let asciiUpperZ = UInt8(ascii: "Z")
6565
private func fromHexDigit(_ c: UnicodeScalar) -> UInt32? {
6666
let n = c.value
6767
if n >= 48 && n <= 57 {
68-
return n - 48
68+
return UInt32(n - 48)
6969
}
7070
switch n {
7171
case 65, 97: return 10

Sources/SwiftProtobuf/TextFormatScanner.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ private func fromHexDigit(_ c: UInt8) -> UInt8? {
7070
return c - asciiZero
7171
}
7272
if c >= asciiUpperA && c <= asciiUpperF {
73-
return c - asciiUpperA + 10
73+
return c - asciiUpperA + UInt8(10)
7474
}
7575
if c >= asciiLowerA && c <= asciiLowerF {
76-
return c - asciiLowerA + 10
76+
return c - asciiLowerA + UInt8(10)
7777
}
7878
return nil
7979
}

Sources/protoc-gen-swift/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ struct GeneratorPlugin {
8686
showVersion()
8787
print(Version.copyright)
8888
print("")
89-
90-
let version = SwiftProtobuf.Version
89+
90+
let version = SwiftProtobuf.Version.self
9191
let packageVersion = "\(version.major),\(version.minor),\(version.revision)"
9292

9393
let help = (

Tests/SwiftProtobufTests/Test_JSON.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class Test_JSON: XCTestCase, PBTestHelpers {
367367
assertJSONDecodeFails("{\"singleUint64\":01}")
368368
assertJSONDecodeFails("{\"singleUint64\":\"01\"}")
369369
// But it does accept exponential (as long as result is integral)
370-
assertJSONDecodeSucceeds("{\"singleUint64\":4.294967295e9}") {$0.singleUint64 == UInt32.max}
370+
assertJSONDecodeSucceeds("{\"singleUint64\":4.294967295e9}") {$0.singleUint64 == UInt64(UInt32.max)}
371371
assertJSONDecodeSucceeds("{\"singleUint64\":1e3}") {$0.singleUint64 == 1000}
372372
assertJSONDecodeSucceeds("{\"singleUint64\":1.2e3}") {$0.singleUint64 == 1200}
373373
assertJSONDecodeSucceeds("{\"singleUint64\":1000e-2}") {$0.singleUint64 == 10}

0 commit comments

Comments
 (0)