Skip to content

Commit f40ca4d

Browse files
committed
Fix Swift 4.1 warnings
1 parent c052d41 commit f40ca4d

13 files changed

+28
-30
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: objective-c
22
rvm: 2.3
3-
osx_image: xcode9
3+
osx_image: xcode9.3
44
env:
55
global:
66
- IOS_SIMULATOR="iPhone 6s"

SQLite.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@
680680
isa = PBXProject;
681681
attributes = {
682682
LastSwiftUpdateCheck = 0720;
683-
LastUpgradeCheck = 0900;
683+
LastUpgradeCheck = 0930;
684684
TargetAttributes = {
685685
03A65E591C6BB0F50062603F = {
686686
CreatedOnToolsVersion = 7.2;
@@ -1148,12 +1148,14 @@
11481148
CLANG_WARN_BOOL_CONVERSION = YES;
11491149
CLANG_WARN_COMMA = YES;
11501150
CLANG_WARN_CONSTANT_CONVERSION = YES;
1151+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
11511152
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
11521153
CLANG_WARN_EMPTY_BODY = YES;
11531154
CLANG_WARN_ENUM_CONVERSION = YES;
11541155
CLANG_WARN_INFINITE_RECURSION = YES;
11551156
CLANG_WARN_INT_CONVERSION = YES;
11561157
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
1158+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
11571159
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
11581160
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
11591161
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -1206,12 +1208,14 @@
12061208
CLANG_WARN_BOOL_CONVERSION = YES;
12071209
CLANG_WARN_COMMA = YES;
12081210
CLANG_WARN_CONSTANT_CONVERSION = YES;
1211+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
12091212
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
12101213
CLANG_WARN_EMPTY_BODY = YES;
12111214
CLANG_WARN_ENUM_CONVERSION = YES;
12121215
CLANG_WARN_INFINITE_RECURSION = YES;
12131216
CLANG_WARN_INT_CONVERSION = YES;
12141217
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
1218+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
12151219
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
12161220
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
12171221
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;

SQLite.xcodeproj/xcshareddata/xcschemes/SQLite Mac.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
<TestableReference
@@ -56,7 +55,6 @@
5655
buildConfiguration = "Debug"
5756
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5857
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59-
language = ""
6058
launchStyle = "0"
6159
useCustomWorkingDirectory = "NO"
6260
ignoresPersistentStateOnLaunch = "NO"

SQLite.xcodeproj/xcshareddata/xcschemes/SQLite iOS.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
<TestableReference
@@ -56,7 +55,6 @@
5655
buildConfiguration = "Debug"
5756
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5857
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59-
language = ""
6058
launchStyle = "0"
6159
useCustomWorkingDirectory = "NO"
6260
ignoresPersistentStateOnLaunch = "NO"

SQLite.xcodeproj/xcshareddata/xcschemes/SQLite tvOS.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
<TestableReference
@@ -56,7 +55,6 @@
5655
buildConfiguration = "Debug"
5756
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5857
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59-
language = ""
6058
launchStyle = "0"
6159
useCustomWorkingDirectory = "NO"
6260
ignoresPersistentStateOnLaunch = "NO"

SQLite.xcodeproj/xcshareddata/xcschemes/SQLite watchOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Sources/SQLite/Typed/Coding.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fileprivate class SQLiteDecoder : Decoder {
217217
}
218218

219219
var allKeys: [Key] {
220-
return self.row.columnNames.keys.flatMap({Key(stringValue: $0)})
220+
return self.row.columnNames.keys.compactMap({Key(stringValue: $0)})
221221
}
222222

223223
func contains(_ key: Key) -> Bool {

Sources/SQLite/Typed/CoreFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ extension ExpressionType where UnderlyingType == String? {
637637

638638
}
639639

640-
extension Collection where Iterator.Element : Value, IndexDistance == Int {
640+
extension Collection where Iterator.Element : Value {
641641

642642
/// Builds a copy of the expression prepended with an `IN` check against the
643643
/// collection.

Sources/SQLite/Typed/Query.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ extension QueryType {
647647
whereClause
648648
]
649649

650-
return Insert(" ".join(clauses.flatMap { $0 }).expression)
650+
return Insert(" ".join(clauses.compactMap { $0 }).expression)
651651
}
652652

653653
/// Runs an `INSERT` statement against the query with `DEFAULT VALUES`.
@@ -690,7 +690,7 @@ extension QueryType {
690690
limitOffsetClause
691691
]
692692

693-
return Update(" ".join(clauses.flatMap { $0 }).expression)
693+
return Update(" ".join(clauses.compactMap { $0 }).expression)
694694
}
695695

696696
// MARK: DELETE
@@ -704,7 +704,7 @@ extension QueryType {
704704
limitOffsetClause
705705
]
706706

707-
return Delete(" ".join(clauses.flatMap { $0 }).expression)
707+
return Delete(" ".join(clauses.compactMap { $0 }).expression)
708708
}
709709

710710
// MARK: EXISTS
@@ -789,7 +789,7 @@ extension QueryType {
789789
limitOffsetClause
790790
]
791791

792-
return " ".join(clauses.flatMap { $0 }).expression
792+
return " ".join(clauses.compactMap { $0 }).expression
793793
}
794794

795795
}

Sources/SQLite/Typed/Schema.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extension Table {
4747
withoutRowid ? Expression<Void>(literal: "WITHOUT ROWID") : nil
4848
]
4949

50-
return " ".join(clauses.flatMap { $0 }).asSQL()
50+
return " ".join(clauses.compactMap { $0 }).asSQL()
5151
}
5252

5353
public func create(_ query: QueryType, temporary: Bool = false, ifNotExists: Bool = false) -> String {
@@ -57,7 +57,7 @@ extension Table {
5757
query
5858
]
5959

60-
return " ".join(clauses.flatMap { $0 }).asSQL()
60+
return " ".join(clauses.compactMap { $0 }).asSQL()
6161
}
6262

6363
// MARK: - ALTER TABLE … ADD COLUMN
@@ -135,7 +135,7 @@ extension Table {
135135
"".wrap(columns) as Expression<Void>
136136
]
137137

138-
return " ".join(clauses.flatMap { $0 }).asSQL()
138+
return " ".join(clauses.compactMap { $0 }).asSQL()
139139
}
140140

141141
// MARK: - DROP INDEX
@@ -174,7 +174,7 @@ extension View {
174174
query
175175
]
176176

177-
return " ".join(clauses.flatMap { $0 }).asSQL()
177+
return " ".join(clauses.compactMap { $0 }).asSQL()
178178
}
179179

180180
// MARK: - DROP VIEW
@@ -196,7 +196,7 @@ extension VirtualTable {
196196
using
197197
]
198198

199-
return " ".join(clauses.flatMap { $0 }).asSQL()
199+
return " ".join(clauses.compactMap { $0 }).asSQL()
200200
}
201201

202202
// MARK: - ALTER TABLE … RENAME TO
@@ -405,7 +405,7 @@ public final class TableBuilder {
405405
delete.map { Expression<Void>(literal: "ON DELETE \($0.rawValue)") }
406406
]
407407

408-
definitions.append(" ".join(clauses.flatMap { $0 }))
408+
definitions.append(" ".join(clauses.compactMap { $0 }))
409409
}
410410

411411
}
@@ -456,7 +456,7 @@ private extension QueryType {
456456
name
457457
]
458458

459-
return " ".join(clauses.flatMap { $0 })
459+
return " ".join(clauses.compactMap { $0 })
460460
}
461461

462462
func rename(to: Self) -> String {
@@ -475,7 +475,7 @@ private extension QueryType {
475475
name
476476
]
477477

478-
return " ".join(clauses.flatMap { $0 }).asSQL()
478+
return " ".join(clauses.compactMap { $0 }).asSQL()
479479
}
480480

481481
}
@@ -493,7 +493,7 @@ private func definition(_ column: Expressible, _ datatype: String, _ primaryKey:
493493
collate.map { " ".join([Expression<Void>(literal: "COLLATE"), $0]) }
494494
]
495495

496-
return " ".join(clauses.flatMap { $0 })
496+
return " ".join(clauses.compactMap { $0 })
497497
}
498498

499499
private func reference(_ primary: (QueryType, Expressible)) -> Expressible {

Tests/SQLiteTests/BlobTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BlobTests : XCTestCase {
1616

1717
func test_init_unsafeRawPointer() {
1818
let pointer = UnsafeMutablePointer<UInt8>.allocate(capacity: 3)
19-
pointer.initialize(to: 42, count: 3)
19+
pointer.initialize(repeating: 42, count: 3)
2020
let blob = Blob(bytes: pointer, length: 3)
2121
XCTAssertEqual(blob.bytes, [42, 42, 42])
2222
}

Tests/SQLiteTests/ConnectionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class ConnectionTests : SQLiteTestCase {
157157

158158
func test_transaction_rollsBackTransactionsIfCommitsFail() {
159159
let sqliteVersion = String(describing: try! db.scalar("SELECT sqlite_version()")!)
160-
.split(separator: ".").flatMap { Int($0) }
160+
.split(separator: ".").compactMap { Int($0) }
161161
// PRAGMA defer_foreign_keys only supported in SQLite >= 3.8.0
162162
guard sqliteVersion[0] == 3 && sqliteVersion[1] >= 8 else {
163163
NSLog("skipping test for SQLite version \(sqliteVersion)")

Tests/SQLiteTests/FTS4Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class FTS4IntegrationTests : SQLiteTestCase {
184184

185185
let locale = CFLocaleCopyCurrent()
186186
let tokenizerName = "tokenizer"
187-
let tokenizer = CFStringTokenizerCreate(nil, "" as CFString!, CFRangeMake(0, 0), UInt(kCFStringTokenizerUnitWord), locale)
187+
let tokenizer = CFStringTokenizerCreate(nil, "" as CFString, CFRangeMake(0, 0), UInt(kCFStringTokenizerUnitWord), locale)
188188
try! db.registerTokenizer(tokenizerName) { string in
189189
CFStringTokenizerSetString(tokenizer, string as CFString, CFRangeMake(0, CFStringGetLength(string as CFString)))
190190
if CFStringTokenizerAdvanceToNextToken(tokenizer).isEmpty {

0 commit comments

Comments
 (0)