Skip to content

Commit a72b703

Browse files
author
David Ungar
authored
Merge pull request #450 from davidungar/check-write-against-read
[Incremental] Add code to compare ModuleDepGraphs, & strengthen testRoundTripFixtures with it
2 parents 1d11f11 + 47f8b77 commit a72b703

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

Sources/SwiftDriver/IncrementalCompilation/DictionaryOfDictionaries.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ extension DictionaryOfDictionaries {
138138

139139
// MARK: - identity
140140

141-
extension DictionaryOfDictionaries: Equatable where Value: Equatable {}
141+
extension DictionaryOfDictionaries: Equatable where Value: Equatable {}

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraph.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,3 +914,35 @@ extension Diagnostic.Message {
914914
}
915915
}
916916

917+
// MARK: - Checking Serialization
918+
919+
extension ModuleDependencyGraph {
920+
func matches(_ other: ModuleDependencyGraph) -> Bool {
921+
guard nodeFinder.matches(other.nodeFinder),
922+
tracedNodes.matches(other.tracedNodes),
923+
sourceSwiftDepsMap.matches(other.sourceSwiftDepsMap),
924+
externalDependencies.matches(other.externalDependencies)
925+
else {
926+
return false
927+
}
928+
return true
929+
}
930+
}
931+
932+
extension Set where Element == ModuleDependencyGraph.Node {
933+
fileprivate func matches(_ other: Self) -> Bool {
934+
self == other
935+
}
936+
}
937+
938+
extension BidirectionalMap where T1 == TypedVirtualPath, T2 == ModuleDependencyGraph.SwiftDeps {
939+
fileprivate func matches(_ other: Self) -> Bool {
940+
self == other
941+
}
942+
}
943+
944+
extension Set where Element == ExternalDependency {
945+
fileprivate func matches(_ other: Self) -> Bool {
946+
self == other
947+
}
948+
}

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/NodeFinder.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,10 @@ fileprivate extension ModuleDependencyGraph.DependencySource {
248248
file.name
249249
}
250250
}
251+
252+
// MARK: - Checking Serialization
253+
extension ModuleDependencyGraph.NodeFinder {
254+
func matches(_ other: Self) -> Bool {
255+
nodeMap == other.nodeMap && usesByDef == other.usesByDef
256+
}
257+
}

0 commit comments

Comments
 (0)