Skip to content

Remove @_spi's that were preventing compilation #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public struct Driver {
/// Info needed to write and maybe read the build record.
/// Only present when the driver will be writing the record.
/// Only used for reading when compiling incrementally.
@_spi(Testing) public let buildRecordInfo: BuildRecordInfo?
let buildRecordInfo: BuildRecordInfo?

/// Code & data for incremental compilation. Nil if not running in incremental mode
@_spi(Testing) public let incrementalCompilationState: IncrementalCompilationState?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ extension BuildRecord {
)
}

@_spi(Testing) public func encode() throws -> String {
func encode() throws -> String {
let pathsAndInfos = try inputInfos.map {
input, inputInfo -> (String, InputInfo) in
guard let path = input.absolutePath else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SwiftOptions

/// Holds information required to read and write the build record (aka compilation record)
/// This info is always written, but only read for incremental compilation.
@_spi(Testing) public class BuildRecordInfo {
class BuildRecordInfo {
let buildRecordPath: VirtualPath
let fileSystem: FileSystem
let argsHash: String
Expand Down
20 changes: 10 additions & 10 deletions Sources/SwiftDriver/Incremental Compilation/DependencyKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import Foundation

/// A filename from another module
@_spi(Testing) public struct ExternalDependency: Hashable, CustomStringConvertible {
struct ExternalDependency: Hashable, CustomStringConvertible {
let fileName: String

var file: VirtualPath? {
try? VirtualPath(path: fileName)
}
@_spi(Testing) public init(_ path: String) {
init(_ path: String) {
self.fileName = path
}
public var description: String {
Expand All @@ -18,7 +18,7 @@ import Foundation



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

@_spi(Testing) public enum DeclAspect {
enum DeclAspect {
case interface, implementation
}

/// Encode the current sorts of dependencies as kinds of nodes in the dependency
/// graph, splitting the current *member* into \ref member and \ref
/// potentialMember and adding \ref sourceFileProvide.
///
@_spi(Testing) public enum Designator: Hashable {
enum Designator: Hashable {
case
topLevel(name: String),
dynamicLookup(name: String),
Expand All @@ -60,13 +60,13 @@ import Foundation
default:
return nil}
}
}
}

@_spi(Testing) public let aspect: DeclAspect
@_spi(Testing) public let designator: Designator
let aspect: DeclAspect
let designator: Designator


@_spi(Testing) public init(
init(
aspect: DeclAspect,
designator: Designator)
{
Expand All @@ -75,7 +75,7 @@ import Foundation
}


@_spi(Testing) public var correspondingImplementation: Self {
var correspondingImplementation: Self {
assert(aspect == .interface)
return Self(aspect: .implementation, designator: designator)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/// It supports iterating over all 2nd-level pairs. See `subscript(key: OuterKey)`

import Foundation
@_spi(Testing) public struct DictionaryOfDictionaries<OuterKey: Hashable, InnerKey: Hashable, Value>: Collection {
struct DictionaryOfDictionaries<OuterKey: Hashable, InnerKey: Hashable, Value>: Collection {
public typealias InnerDict = [InnerKey: Value]
public typealias OuterDict = [OuterKey: InnerDict]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class IncrementalCompilationState {

// MARK: - Creating IncrementalCompilationState if possible
/// Return nil if not compiling incrementally
@_spi(Testing) public init?(
init?(
buildRecordInfo: BuildRecordInfo?,
compilerMode: CompilerMode,
diagnosticEngine: DiagnosticsEngine,
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftDriver/Incremental Compilation/InputInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import TSCBasic

public struct InputInfo: Equatable {

@_spi(Testing) public let status: Status
@_spi(Testing) public let previousModTime: Date
let status: Status
let previousModTime: Date

public init(status: Status, previousModTime: Date) {
self.status = status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ extension ModuleDependencyGraph {
// MARK: Integrator - state & creation

/// Integrates a \c SourceFileDependencyGraph into a \c ModuleDependencyGraph
@_spi(Testing) public struct Integrator {
struct Integrator {

// Shorthands
@_spi(Testing) public typealias Graph = ModuleDependencyGraph
typealias Graph = ModuleDependencyGraph

@_spi(Testing) public typealias Changes = Set<Node>
typealias Changes = Set<Node>

let source: SourceFileDependencyGraph
let swiftDeps: SwiftDeps
Expand Down Expand Up @@ -55,7 +55,7 @@ extension ModuleDependencyGraph.Integrator {
case notSwiftDeps
}
/// returns nil for error
@_spi(Testing) public static func integrate(
static func integrate(
swiftDeps: Graph.SwiftDeps,
into destination: Graph,
diagnosticEngine: DiagnosticsEngine
Expand All @@ -76,7 +76,7 @@ extension ModuleDependencyGraph.Integrator {
/// Integrate a SourceFileDepGraph into the receiver.
/// Integration happens when the driver needs to read SourceFileDepGraph.
/// Returns changed nodes
@_spi(Testing) public static func integrate(
static func integrate(
from g: SourceFileDependencyGraph,
swiftDeps: Graph.SwiftDeps,
into destination: Graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ extension ModuleDependencyGraph {
///
/// Use a class, not a struct because otherwise it would be duplicated for each thing it uses

@_spi(Testing) public final class Node {
final class Node {

@_spi(Testing) public typealias Graph = ModuleDependencyGraph
typealias Graph = ModuleDependencyGraph

/// Def->use arcs go by DependencyKey. There may be >1 node for a given key.
let dependencyKey: DependencyKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension ModuleDependencyGraph {
/// The core information for the ModuleDependencyGraph
/// Isolate in a sub-structure in order to faciliate invariant maintainance
struct NodeFinder {
@_spi(Testing) public typealias Graph = ModuleDependencyGraph
typealias Graph = ModuleDependencyGraph

/// Maps swiftDeps files and DependencyKeys to Nodes
fileprivate typealias NodeMap = TwoDMap<SwiftDeps?, DependencyKey, Node>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import TSCBasic

// MARK: - SwiftDeps
extension ModuleDependencyGraph {
@_spi(Testing) public struct SwiftDeps: Hashable, CustomStringConvertible {
struct SwiftDeps: Hashable, CustomStringConvertible {

let file: VirtualPath

@_spi(Testing) public init?(_ typedFile: TypedVirtualPath) {
init?(_ typedFile: TypedVirtualPath) {
guard typedFile.type == .swiftDeps else { return nil }
self.init(typedFile.file)
}
init(_ file: VirtualPath) {
self.file = file
}
@_spi(Testing) public init(mock i: Int) {
init(mock i: Int) {
self.file = try! VirtualPath(path: String(i))
}
@_spi(Testing) public var mockID: Int {
var mockID: Int {
Int(file.name)!
}
public var description: String {
Expand All @@ -39,10 +39,10 @@ extension ModuleDependencyGraph {

// MARK: - testing
extension ModuleDependencyGraph.SwiftDeps {
@_spi(Testing) public var sourceFileProvideNameForMockSwiftDeps: String {
var sourceFileProvideNameForMockSwiftDeps: String {
file.name
}
@_spi(Testing) public var interfaceHashForMockSwiftDeps: String {
var interfaceHashForMockSwiftDeps: String {
file.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import TSCBasic
extension ModuleDependencyGraph {

/// Trace dependencies through the graph
@_spi(Testing) public struct Tracer {
@_spi(Testing) public typealias Graph = ModuleDependencyGraph
struct Tracer {
typealias Graph = ModuleDependencyGraph

let startingPoints: [Node]
let graph: ModuleDependencyGraph

@_spi(Testing) public private(set) var tracedUses: [Node] = []
private(set) var tracedUses: [Node] = []

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

/// Find all uses of `defs` that have not already been traced.
/// (If already traced, jobs have already been scheduled.)
@_spi(Testing) public static func findPreviouslyUntracedUsesOf<Nodes: Sequence> (
static func findPreviouslyUntracedUsesOf<Nodes: Sequence> (
defs: Nodes,
in graph: ModuleDependencyGraph,
diagnosticEngine: DiagnosticsEngine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ import SwiftOptions

// MARK: - ModuleDependencyGraph

@_spi(Testing) public final class ModuleDependencyGraph {
final class ModuleDependencyGraph {

internal var nodeFinder = NodeFinder()
var nodeFinder = NodeFinder()

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

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

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

let verifyDependencyGraphAfterEveryImport: Bool
let emitDependencyDotFileAfterEveryImport: Bool
let reportIncrementalDecision: ((String, TypedVirtualPath?) -> Void)?

@_spi(Testing) public let diagnosticEngine: DiagnosticsEngine
private let diagnosticEngine: DiagnosticsEngine

public init(
diagnosticEngine: DiagnosticsEngine,
Expand Down Expand Up @@ -89,7 +89,7 @@ extension ModuleDependencyGraph {
extension ModuleDependencyGraph {
/// Find all the sources that depend on `sourceFile`. For some source files, these will be
/// speculatively scheduled in the first wave.
@_spi(Testing) public func findDependentSourceFiles(
func findDependentSourceFiles(
of sourceFile: TypedVirtualPath,
_ reportIncrementalDecision: ((String, TypedVirtualPath?) -> Void)?
) -> [TypedVirtualPath] {
Expand All @@ -113,7 +113,7 @@ extension ModuleDependencyGraph {

/// Find all the swiftDeps files that depend on `swiftDeps`.
/// Really private, except for testing.
@_spi(Testing) public func findSwiftDepsToRecompileWhenWholeSwiftDepsChanges(
func findSwiftDepsToRecompileWhenWholeSwiftDepsChanges(
_ swiftDeps: SwiftDeps
) -> Set<SwiftDeps> {
let nodes = nodeFinder.findNodes(for: swiftDeps) ?? [:]
Expand All @@ -126,7 +126,7 @@ extension ModuleDependencyGraph {
/// After `source` has been compiled, figure out what other source files need compiling.
/// Used to schedule the 2nd wave.
/// Return nil in case of an error.
@_spi(Testing) public func findSourcesToCompileAfterCompiling(
func findSourcesToCompileAfterCompiling(
_ source: TypedVirtualPath
) -> [TypedVirtualPath]? {
findSourcesToCompileAfterIntegrating( sourceSwiftDepsMap[source] )
Expand All @@ -152,7 +152,7 @@ extension ModuleDependencyGraph {
// MARK: - Scheduling either wave
extension ModuleDependencyGraph {
/// Find all the swiftDeps affected when the nodes change.
@_spi(Testing) public func findSwiftDepsToRecompileWhenNodesChange<Nodes: Sequence>(
func findSwiftDepsToRecompileWhenNodesChange<Nodes: Sequence>(
_ nodes: Nodes
) -> Set<SwiftDeps>
where Nodes.Element == Node
Expand All @@ -165,7 +165,7 @@ extension ModuleDependencyGraph {
return Set(affectedNodes.compactMap {$0.swiftDeps})
}

@_spi(Testing) public func forEachUntracedSwiftDepsDirectlyDependent(
func forEachUntracedSwiftDepsDirectlyDependent(
on externalSwiftDeps: ExternalDependency,
_ fn: (SwiftDeps) -> Void
) {
Expand Down Expand Up @@ -205,7 +205,7 @@ extension ModuleDependencyGraph {
// MARK: - utilities for unit testing
extension ModuleDependencyGraph {
/// Testing only
@_spi(Testing) public func haveAnyNodesBeenTraversed(inMock i: Int) -> Bool {
func haveAnyNodesBeenTraversed(inMock i: Int) -> Bool {
let swiftDeps = SwiftDeps(mock: i)
// optimization
if let fileNode = nodeFinder.findFileInterfaceNode(forMock: swiftDeps),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

/// Like a Dictionary, but can have >1 value per key (i.e., a multimap)
@_spi(Testing) public struct Multidictionary<Key: Hashable, Value: Hashable>: Collection {
struct Multidictionary<Key: Hashable, Value: Hashable>: Collection {
public typealias OuterDict = [Key: Set<Value>]
public typealias InnerSet = Set<Value>
private var outerDict = OuterDict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import Foundation
import TSCUtility

@_spi(Testing) public struct SourceFileDependencyGraph {
struct SourceFileDependencyGraph {
public static let sourceFileProvidesInterfaceSequenceNumber: Int = 0
public static let sourceFileProvidesImplementationSequenceNumber: Int = 1

Expand Down Expand Up @@ -62,7 +62,7 @@ extension SourceFileDependencyGraph {
public var defsIDependUpon: [Int]
public var isProvides: Bool

@_spi(Testing) public init(
init(
key: DependencyKey,
fingerprint: String?,
sequenceNumber: Int,
Expand Down Expand Up @@ -126,21 +126,21 @@ extension SourceFileDependencyGraph {
return try self.init(pathString: path.pathString)
}

@_spi(Testing) public init(nodesForTesting: [Node]) {
init(nodesForTesting: [Node]) {
majorVersion = 0
minorVersion = 0
compilerVersionString = ""
allNodes = nodesForTesting
}

// FIXME: This should accept a FileSystem parameter.
@_spi(Testing) public init(pathString: String) throws {
init(pathString: String) throws {
let data = try Data(contentsOf: URL(fileURLWithPath: pathString))
try self.init(data: data)
}

@_spi(Testing) public init(data: Data,
fromSwiftModule extractFromSwiftModule: Bool = false) throws {
init(data: Data,
fromSwiftModule extractFromSwiftModule: Bool = false) throws {
struct Visitor: BitstreamVisitor {
let extractFromSwiftModule: Bool

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Incremental Compilation/TwoDMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


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

private var map1 = DictionaryOfDictionaries<Key1, Key2, Value>()
private var map2 = DictionaryOfDictionaries<Key2, Key1, Value>()
Expand Down
Loading