Skip to content

Commit 6a47766

Browse files
author
David Ungar
authored
Merge pull request #362 from davidungar/rm-spis
Remove @_spi's that were preventing compilation
2 parents 3492dc6 + 191f8a9 commit 6a47766

20 files changed

+59
-59
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public struct Driver {
195195
/// Info needed to write and maybe read the build record.
196196
/// Only present when the driver will be writing the record.
197197
/// Only used for reading when compiling incrementally.
198-
@_spi(Testing) public let buildRecordInfo: BuildRecordInfo?
198+
let buildRecordInfo: BuildRecordInfo?
199199

200200
/// Code & data for incremental compilation. Nil if not running in incremental mode
201201
@_spi(Testing) public let incrementalCompilationState: IncrementalCompilationState?

Sources/SwiftDriver/Incremental Compilation/BuildRecord.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ extension BuildRecord {
163163
)
164164
}
165165

166-
@_spi(Testing) public func encode() throws -> String {
166+
func encode() throws -> String {
167167
let pathsAndInfos = try inputInfos.map {
168168
input, inputInfo -> (String, InputInfo) in
169169
guard let path = input.absolutePath else {

Sources/SwiftDriver/Incremental Compilation/BuildRecordInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import SwiftOptions
1616

1717
/// Holds information required to read and write the build record (aka compilation record)
1818
/// This info is always written, but only read for incremental compilation.
19-
@_spi(Testing) public class BuildRecordInfo {
19+
class BuildRecordInfo {
2020
let buildRecordPath: VirtualPath
2121
let fileSystem: FileSystem
2222
let argsHash: String

Sources/SwiftDriver/Incremental Compilation/DependencyKey.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import Foundation
33

44
/// A filename from another module
5-
@_spi(Testing) public struct ExternalDependency: Hashable, CustomStringConvertible {
5+
struct ExternalDependency: Hashable, CustomStringConvertible {
66
let fileName: String
77

88
var file: VirtualPath? {
99
try? VirtualPath(path: fileName)
1010
}
11-
@_spi(Testing) public init(_ path: String) {
11+
init(_ path: String) {
1212
self.fileName = path
1313
}
1414
public var description: String {
@@ -18,7 +18,7 @@ import Foundation
1818

1919

2020

21-
@_spi(Testing) public struct DependencyKey: Hashable {
21+
public struct DependencyKey: Hashable {
2222
/// Instead of the status quo scheme of two kinds of "Depends", cascading and
2323
/// non-cascading this code represents each entity ("Provides" in the status
2424
/// quo), by a pair of nodes. One node represents the "implementation." If the
@@ -31,15 +31,15 @@ import Foundation
3131
/// implementations white. Each node holds an instance variable describing which
3232
/// aspect of the entity it represents.
3333

34-
@_spi(Testing) public enum DeclAspect {
34+
enum DeclAspect {
3535
case interface, implementation
3636
}
3737

3838
/// Encode the current sorts of dependencies as kinds of nodes in the dependency
3939
/// graph, splitting the current *member* into \ref member and \ref
4040
/// potentialMember and adding \ref sourceFileProvide.
4141
///
42-
@_spi(Testing) public enum Designator: Hashable {
42+
enum Designator: Hashable {
4343
case
4444
topLevel(name: String),
4545
dynamicLookup(name: String),
@@ -60,13 +60,13 @@ import Foundation
6060
default:
6161
return nil}
6262
}
63-
}
63+
}
6464

65-
@_spi(Testing) public let aspect: DeclAspect
66-
@_spi(Testing) public let designator: Designator
65+
let aspect: DeclAspect
66+
let designator: Designator
6767

6868

69-
@_spi(Testing) public init(
69+
init(
7070
aspect: DeclAspect,
7171
designator: Designator)
7272
{
@@ -75,7 +75,7 @@ import Foundation
7575
}
7676

7777

78-
@_spi(Testing) public var correspondingImplementation: Self {
78+
var correspondingImplementation: Self {
7979
assert(aspect == .interface)
8080
return Self(aspect: .implementation, designator: designator)
8181
}

Sources/SwiftDriver/Incremental Compilation/DictionaryOfDictionaries.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// It supports iterating over all 2nd-level pairs. See `subscript(key: OuterKey)`
1515

1616
import Foundation
17-
@_spi(Testing) public struct DictionaryOfDictionaries<OuterKey: Hashable, InnerKey: Hashable, Value>: Collection {
17+
struct DictionaryOfDictionaries<OuterKey: Hashable, InnerKey: Hashable, Value>: Collection {
1818
public typealias InnerDict = [InnerKey: Value]
1919
public typealias OuterDict = [OuterKey: InnerDict]
2020

Sources/SwiftDriver/Incremental Compilation/IncrementalCompilationState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class IncrementalCompilationState {
4949

5050
// MARK: - Creating IncrementalCompilationState if possible
5151
/// Return nil if not compiling incrementally
52-
@_spi(Testing) public init?(
52+
init?(
5353
buildRecordInfo: BuildRecordInfo?,
5454
compilerMode: CompilerMode,
5555
diagnosticEngine: DiagnosticsEngine,

Sources/SwiftDriver/Incremental Compilation/InputInfo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import TSCBasic
1414

1515
public struct InputInfo: Equatable {
1616

17-
@_spi(Testing) public let status: Status
18-
@_spi(Testing) public let previousModTime: Date
17+
let status: Status
18+
let previousModTime: Date
1919

2020
public init(status: Status, previousModTime: Date) {
2121
self.status = status

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/Integrator.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ extension ModuleDependencyGraph {
1717
// MARK: Integrator - state & creation
1818

1919
/// Integrates a \c SourceFileDependencyGraph into a \c ModuleDependencyGraph
20-
@_spi(Testing) public struct Integrator {
20+
struct Integrator {
2121

2222
// Shorthands
23-
@_spi(Testing) public typealias Graph = ModuleDependencyGraph
23+
typealias Graph = ModuleDependencyGraph
2424

25-
@_spi(Testing) public typealias Changes = Set<Node>
25+
typealias Changes = Set<Node>
2626

2727
let source: SourceFileDependencyGraph
2828
let swiftDeps: SwiftDeps
@@ -55,7 +55,7 @@ extension ModuleDependencyGraph.Integrator {
5555
case notSwiftDeps
5656
}
5757
/// returns nil for error
58-
@_spi(Testing) public static func integrate(
58+
static func integrate(
5959
swiftDeps: Graph.SwiftDeps,
6060
into destination: Graph,
6161
diagnosticEngine: DiagnosticsEngine
@@ -76,7 +76,7 @@ extension ModuleDependencyGraph.Integrator {
7676
/// Integrate a SourceFileDepGraph into the receiver.
7777
/// Integration happens when the driver needs to read SourceFileDepGraph.
7878
/// Returns changed nodes
79-
@_spi(Testing) public static func integrate(
79+
static func integrate(
8080
from g: SourceFileDependencyGraph,
8181
swiftDeps: Graph.SwiftDeps,
8282
into destination: Graph

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/Node.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ extension ModuleDependencyGraph {
2424
///
2525
/// Use a class, not a struct because otherwise it would be duplicated for each thing it uses
2626

27-
@_spi(Testing) public final class Node {
27+
final class Node {
2828

29-
@_spi(Testing) public typealias Graph = ModuleDependencyGraph
29+
typealias Graph = ModuleDependencyGraph
3030

3131
/// Def->use arcs go by DependencyKey. There may be >1 node for a given key.
3232
let dependencyKey: DependencyKey

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/NodeFinder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension ModuleDependencyGraph {
1717
/// The core information for the ModuleDependencyGraph
1818
/// Isolate in a sub-structure in order to faciliate invariant maintainance
1919
struct NodeFinder {
20-
@_spi(Testing) public typealias Graph = ModuleDependencyGraph
20+
typealias Graph = ModuleDependencyGraph
2121

2222
/// Maps swiftDeps files and DependencyKeys to Nodes
2323
fileprivate typealias NodeMap = TwoDMap<SwiftDeps?, DependencyKey, Node>

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/SwiftDeps.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ import TSCBasic
1414

1515
// MARK: - SwiftDeps
1616
extension ModuleDependencyGraph {
17-
@_spi(Testing) public struct SwiftDeps: Hashable, CustomStringConvertible {
17+
struct SwiftDeps: Hashable, CustomStringConvertible {
1818

1919
let file: VirtualPath
2020

21-
@_spi(Testing) public init?(_ typedFile: TypedVirtualPath) {
21+
init?(_ typedFile: TypedVirtualPath) {
2222
guard typedFile.type == .swiftDeps else { return nil }
2323
self.init(typedFile.file)
2424
}
2525
init(_ file: VirtualPath) {
2626
self.file = file
2727
}
28-
@_spi(Testing) public init(mock i: Int) {
28+
init(mock i: Int) {
2929
self.file = try! VirtualPath(path: String(i))
3030
}
31-
@_spi(Testing) public var mockID: Int {
31+
var mockID: Int {
3232
Int(file.name)!
3333
}
3434
public var description: String {
@@ -39,10 +39,10 @@ extension ModuleDependencyGraph {
3939

4040
// MARK: - testing
4141
extension ModuleDependencyGraph.SwiftDeps {
42-
@_spi(Testing) public var sourceFileProvideNameForMockSwiftDeps: String {
42+
var sourceFileProvideNameForMockSwiftDeps: String {
4343
file.name
4444
}
45-
@_spi(Testing) public var interfaceHashForMockSwiftDeps: String {
45+
var interfaceHashForMockSwiftDeps: String {
4646
file.name
4747
}
4848
}

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/Tracer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import TSCBasic
1515
extension ModuleDependencyGraph {
1616

1717
/// Trace dependencies through the graph
18-
@_spi(Testing) public struct Tracer {
19-
@_spi(Testing) public typealias Graph = ModuleDependencyGraph
18+
struct Tracer {
19+
typealias Graph = ModuleDependencyGraph
2020

2121
let startingPoints: [Node]
2222
let graph: ModuleDependencyGraph
2323

24-
@_spi(Testing) public private(set) var tracedUses: [Node] = []
24+
private(set) var tracedUses: [Node] = []
2525

2626
/// Record the paths taking so that -driver-show-incremental can explain why things are recompiled
2727
/// If tracing dependencies, holds a vector used to hold the current path
@@ -37,7 +37,7 @@ extension ModuleDependencyGraph.Tracer {
3737

3838
/// Find all uses of `defs` that have not already been traced.
3939
/// (If already traced, jobs have already been scheduled.)
40-
@_spi(Testing) public static func findPreviouslyUntracedUsesOf<Nodes: Sequence> (
40+
static func findPreviouslyUntracedUsesOf<Nodes: Sequence> (
4141
defs: Nodes,
4242
in graph: ModuleDependencyGraph,
4343
diagnosticEngine: DiagnosticsEngine

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ import SwiftOptions
1616

1717
// MARK: - ModuleDependencyGraph
1818

19-
@_spi(Testing) public final class ModuleDependencyGraph {
19+
final class ModuleDependencyGraph {
2020

21-
internal var nodeFinder = NodeFinder()
21+
var nodeFinder = NodeFinder()
2222

2323
/// When integrating a change, want to find untraced nodes so we can kick off jobs that have not been
2424
/// kicked off yet
2525
private var tracedNodes = Set<Node>()
2626

27-
@_spi(Testing) public var sourceSwiftDepsMap = BidirectionalMap<TypedVirtualPath, SwiftDeps>()
27+
private(set) var sourceSwiftDepsMap = BidirectionalMap<TypedVirtualPath, SwiftDeps>()
2828

2929
// Supports requests from the driver to getExternalDependencies.
30-
@_spi(Testing) public internal(set) var externalDependencies = Set<ExternalDependency>()
30+
public internal(set) var externalDependencies = Set<ExternalDependency>()
3131

3232
let verifyDependencyGraphAfterEveryImport: Bool
3333
let emitDependencyDotFileAfterEveryImport: Bool
3434
let reportIncrementalDecision: ((String, TypedVirtualPath?) -> Void)?
3535

36-
@_spi(Testing) public let diagnosticEngine: DiagnosticsEngine
36+
private let diagnosticEngine: DiagnosticsEngine
3737

3838
public init(
3939
diagnosticEngine: DiagnosticsEngine,
@@ -89,7 +89,7 @@ extension ModuleDependencyGraph {
8989
extension ModuleDependencyGraph {
9090
/// Find all the sources that depend on `sourceFile`. For some source files, these will be
9191
/// speculatively scheduled in the first wave.
92-
@_spi(Testing) public func findDependentSourceFiles(
92+
func findDependentSourceFiles(
9393
of sourceFile: TypedVirtualPath,
9494
_ reportIncrementalDecision: ((String, TypedVirtualPath?) -> Void)?
9595
) -> [TypedVirtualPath] {
@@ -113,7 +113,7 @@ extension ModuleDependencyGraph {
113113

114114
/// Find all the swiftDeps files that depend on `swiftDeps`.
115115
/// Really private, except for testing.
116-
@_spi(Testing) public func findSwiftDepsToRecompileWhenWholeSwiftDepsChanges(
116+
func findSwiftDepsToRecompileWhenWholeSwiftDepsChanges(
117117
_ swiftDeps: SwiftDeps
118118
) -> Set<SwiftDeps> {
119119
let nodes = nodeFinder.findNodes(for: swiftDeps) ?? [:]
@@ -126,7 +126,7 @@ extension ModuleDependencyGraph {
126126
/// After `source` has been compiled, figure out what other source files need compiling.
127127
/// Used to schedule the 2nd wave.
128128
/// Return nil in case of an error.
129-
@_spi(Testing) public func findSourcesToCompileAfterCompiling(
129+
func findSourcesToCompileAfterCompiling(
130130
_ source: TypedVirtualPath
131131
) -> [TypedVirtualPath]? {
132132
findSourcesToCompileAfterIntegrating( sourceSwiftDepsMap[source] )
@@ -152,7 +152,7 @@ extension ModuleDependencyGraph {
152152
// MARK: - Scheduling either wave
153153
extension ModuleDependencyGraph {
154154
/// Find all the swiftDeps affected when the nodes change.
155-
@_spi(Testing) public func findSwiftDepsToRecompileWhenNodesChange<Nodes: Sequence>(
155+
func findSwiftDepsToRecompileWhenNodesChange<Nodes: Sequence>(
156156
_ nodes: Nodes
157157
) -> Set<SwiftDeps>
158158
where Nodes.Element == Node
@@ -165,7 +165,7 @@ extension ModuleDependencyGraph {
165165
return Set(affectedNodes.compactMap {$0.swiftDeps})
166166
}
167167

168-
@_spi(Testing) public func forEachUntracedSwiftDepsDirectlyDependent(
168+
func forEachUntracedSwiftDepsDirectlyDependent(
169169
on externalSwiftDeps: ExternalDependency,
170170
_ fn: (SwiftDeps) -> Void
171171
) {
@@ -205,7 +205,7 @@ extension ModuleDependencyGraph {
205205
// MARK: - utilities for unit testing
206206
extension ModuleDependencyGraph {
207207
/// Testing only
208-
@_spi(Testing) public func haveAnyNodesBeenTraversed(inMock i: Int) -> Bool {
208+
func haveAnyNodesBeenTraversed(inMock i: Int) -> Bool {
209209
let swiftDeps = SwiftDeps(mock: i)
210210
// optimization
211211
if let fileNode = nodeFinder.findFileInterfaceNode(forMock: swiftDeps),

Sources/SwiftDriver/Incremental Compilation/Multidictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// Like a Dictionary, but can have >1 value per key (i.e., a multimap)
14-
@_spi(Testing) public struct Multidictionary<Key: Hashable, Value: Hashable>: Collection {
14+
struct Multidictionary<Key: Hashable, Value: Hashable>: Collection {
1515
public typealias OuterDict = [Key: Set<Value>]
1616
public typealias InnerSet = Set<Value>
1717
private var outerDict = OuterDict()

Sources/SwiftDriver/Incremental Compilation/SourceFileDependencyGraph.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import Foundation
1313
import TSCUtility
1414

15-
@_spi(Testing) public struct SourceFileDependencyGraph {
15+
struct SourceFileDependencyGraph {
1616
public static let sourceFileProvidesInterfaceSequenceNumber: Int = 0
1717
public static let sourceFileProvidesImplementationSequenceNumber: Int = 1
1818

@@ -62,7 +62,7 @@ extension SourceFileDependencyGraph {
6262
public var defsIDependUpon: [Int]
6363
public var isProvides: Bool
6464

65-
@_spi(Testing) public init(
65+
init(
6666
key: DependencyKey,
6767
fingerprint: String?,
6868
sequenceNumber: Int,
@@ -126,21 +126,21 @@ extension SourceFileDependencyGraph {
126126
return try self.init(pathString: path.pathString)
127127
}
128128

129-
@_spi(Testing) public init(nodesForTesting: [Node]) {
129+
init(nodesForTesting: [Node]) {
130130
majorVersion = 0
131131
minorVersion = 0
132132
compilerVersionString = ""
133133
allNodes = nodesForTesting
134134
}
135135

136136
// FIXME: This should accept a FileSystem parameter.
137-
@_spi(Testing) public init(pathString: String) throws {
137+
init(pathString: String) throws {
138138
let data = try Data(contentsOf: URL(fileURLWithPath: pathString))
139139
try self.init(data: data)
140140
}
141141

142-
@_spi(Testing) public init(data: Data,
143-
fromSwiftModule extractFromSwiftModule: Bool = false) throws {
142+
init(data: Data,
143+
fromSwiftModule extractFromSwiftModule: Bool = false) throws {
144144
struct Visitor: BitstreamVisitor {
145145
let extractFromSwiftModule: Bool
146146

Sources/SwiftDriver/Incremental Compilation/TwoDMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
/// A map with 2 keys that can iterate in a number of ways
15-
@_spi(Testing) public struct TwoDMap<Key1: Hashable, Key2: Hashable, Value: Equatable>: MutableCollection {
15+
struct TwoDMap<Key1: Hashable, Key2: Hashable, Value: Equatable>: MutableCollection {
1616

1717
private var map1 = DictionaryOfDictionaries<Key1, Key2, Value>()
1818
private var map2 = DictionaryOfDictionaries<Key2, Key1, Value>()

0 commit comments

Comments
 (0)