Skip to content

Commit 504d9d7

Browse files
committed
Pass-down -downgrade-typecheck-interface-error to interface verification job
The interface verification phase should downgrade errors to warnings as an intermediate step to stage it in. This won't fail the build if interface errors occur but it should help users verify project-side fixes.
1 parent a7ec74f commit 504d9d7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ extension Driver {
452452
default: false)
453453
else { return }
454454

455+
let optIn = env["ENABLE_DEFAULT_INTERFACE_VERIFIER"] != nil ||
456+
parsedOptions.hasArgument(.verifyEmittedModuleInterface)
455457
func addVerifyJob(forPrivate: Bool) throws {
456458
let isNeeded =
457459
forPrivate
@@ -464,11 +466,11 @@ extension Driver {
464466
let mergeInterfaceOutputs = emitModuleJob.outputs.filter { $0.type == outputType }
465467
assert(mergeInterfaceOutputs.count == 1,
466468
"Merge module job should only have one swiftinterface output")
467-
let job = try verifyModuleInterfaceJob(interfaceInput: mergeInterfaceOutputs[0])
469+
let job = try verifyModuleInterfaceJob(interfaceInput: mergeInterfaceOutputs[0], optIn: optIn)
468470
addJob(job)
469471
}
470472
try addVerifyJob(forPrivate: false)
471-
try addVerifyJob(forPrivate: true )
473+
try addVerifyJob(forPrivate: true)
472474
}
473475

474476
private mutating func addAutolinkExtractJob(

Sources/SwiftDriver/Jobs/VerifyModuleInterfaceJob.swift

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

1313
extension Driver {
14-
mutating func verifyModuleInterfaceJob(interfaceInput: TypedVirtualPath) throws -> Job {
14+
mutating func verifyModuleInterfaceJob(interfaceInput: TypedVirtualPath, optIn: Bool) throws -> Job {
1515
var commandLine: [Job.ArgTemplate] = swiftCompilerPrefixArgs.map { Job.ArgTemplate.flag($0) }
1616
var inputs: [TypedVirtualPath] = [interfaceInput]
1717
commandLine.appendFlags("-frontend", "-typecheck-module-from-interface")
@@ -26,6 +26,10 @@ extension Driver {
2626
outputs.append(TypedVirtualPath(file: outputPath, type: .diagnostics))
2727
}
2828

29+
// TODO: remove this because we'd like module interface errors to fail the build.
30+
if !optIn && isFrontendArgSupported(.downgradeTypecheckInterfaceError) {
31+
commandLine.appendFlag(.downgradeTypecheckInterfaceError)
32+
}
2933
return Job(
3034
moduleName: moduleOutputInfo.name,
3135
kind: .verifyModuleInterface,

0 commit comments

Comments
 (0)