Skip to content

Commit 96d4c2e

Browse files
author
David Ungar
committed
Use same up-to-date test as legacy driver
1 parent 9d721df commit 96d4c2e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Sources/SwiftDriver/Incremental Compilation/IncrementalCompilationState.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,20 @@ extension IncrementalCompilationState {
272272
}
273273
let modDate = buildRecordInfo.compilationInputModificationDates[input]
274274
?? Date.distantFuture
275-
let previousCompilationStatus = outOfDateBuildRecord
276-
.inputInfos[input.file]?.status ?? .newlyAdded
275+
let inputInfo = outOfDateBuildRecord.inputInfos[input.file]
276+
let previousCompilationStatus = inputInfo?.status ?? .newlyAdded
277+
let previousModTime = inputInfo?.previousModTime
278+
279+
// Because legacy driver reads/writes dates wrt 1970,
280+
// and because converting time intervals to/from Dates from 1970
281+
// exceeds Double precision, must not compare dates directly
282+
var datesMatch: Bool {
283+
modDate.timeIntervalSince1970 == previousModTime?.timeIntervalSince1970
284+
}
277285

278286
switch previousCompilationStatus {
279-
// Using outOfDateBuildRecord.inputInfos[input.file]?.previousModTime
280-
// has some inaccuracy.
281-
// Use outOfDateBuildRecord.buildTime instead
282-
case .upToDate where modDate < outOfDateBuildRecord.buildTime:
287+
288+
case .upToDate where datesMatch:
283289
reportIncrementalDecision?("May skip current input:", input)
284290
return nil
285291

0 commit comments

Comments
 (0)