Skip to content

Commit fdafa37

Browse files
authored
Merge pull request #928 from bitjammer/acgarland/explicit-repl-subcommand
Stop launching REPL when there aren't inputs
2 parents f149d5f + 1cf2fd0 commit fdafa37

File tree

5 files changed

+5
-51
lines changed

5 files changed

+5
-51
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,13 +1488,7 @@ extension Driver {
14881488
switch outputOption.option {
14891489
case .emitImportedModules:
14901490
return .singleCompile
1491-
1492-
case .repl:
1493-
if driverKind == .interactive, !parsedOptions.hasAnyInput {
1494-
diagnosticsEngine.emit(.warning_unnecessary_repl_mode(option: outputOption.option, kind: driverKind))
1495-
}
1496-
fallthrough
1497-
case .lldbRepl:
1491+
case .repl, .lldbRepl:
14981492
return .repl
14991493

15001494
case .deprecatedIntegratedRepl:
@@ -1570,10 +1564,6 @@ extension Driver {
15701564
}
15711565

15721566
extension Diagnostic.Message {
1573-
static func warning_unnecessary_repl_mode(option: Option, kind: DriverKind) -> Diagnostic.Message {
1574-
.warning("unnecessary option '\(option.spelling)'; this is the default for '\(kind.rawValue)' with no input files")
1575-
}
1576-
15771567
static func warn_ignoring_batch_mode(_ option: Option) -> Diagnostic.Message {
15781568
.warning("ignoring '-enable-batch-mode' because '\(option.spelling)' was also specified")
15791569
}

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -746,19 +746,7 @@ extension Driver {
746746
}
747747
return ([try generateDumpPCMJob(input: inputFiles.first!)], nil)
748748
case .intro:
749-
// TODO: Remove this check once the REPL no longer launches
750-
// by default.
751-
if !inputFiles.isEmpty {
752-
throw PlanningError.replReceivedInput
753-
}
754-
// end TODO.
755-
756-
var introJobs = try helpIntroJobs()
757-
758-
// TODO: Remove this to stop launching the REPL by default.
759-
introJobs.append(try replJob())
760-
761-
return (introJobs, nil)
749+
return (try helpIntroJobs(), nil)
762750
}
763751
}
764752
}

Sources/SwiftDriver/Jobs/SwiftHelpIntroJob.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ import SwiftOptions
1414
extension Driver {
1515
mutating func helpIntroJobs() throws -> [Job] {
1616
return [
17-
Job(
18-
moduleName: moduleOutputInfo.name,
19-
kind: .versionRequest,
20-
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
21-
commandLine: [.flag("--version")],
22-
inputs: [],
23-
primaryInputs: [],
24-
outputs: [],
25-
requiresInPlaceExecution: false),
2617
Job(
2718
moduleName: moduleOutputInfo.name,
2819
kind: .help,

Sources/swift-help/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct SwiftHelp: ParsableCommand {
110110
// `repl` not included in `Subcommand`, also print it here.
111111
do {
112112
let padding = String(repeating: " ", count: maxSubcommandNameLength - "repl".count)
113-
print(" \(plainBold)swift repl\(plain)\(padding) Experiment with Swift code interactively (default)")
113+
print(" \(plainBold)swift repl\(plain)\(padding) Experiment with Swift code interactively")
114114
}
115115

116116
print("\n Use \(plainBold)`swift --help`\(plain) for descriptions of available options and flags.")

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,6 @@ final class SwiftDriverTests: XCTestCase {
553553
XCTAssertEqual(driver.moduleOutputInfo.name, "main")
554554
}
555555

556-
try assertDriverDiagnostics(args: "swift", "-repl") { driver, verifier in
557-
verifier.expect(.warning("unnecessary option '-repl'; this is the default for 'swift' with no input files"))
558-
XCTAssertNil(driver.moduleOutputInfo.output)
559-
XCTAssertEqual(driver.moduleOutputInfo.name, "REPL")
560-
}
561-
562556
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "bar.swift", "-emit-library", "-o", "libWibble.so") { driver in
563557
XCTAssertEqual(driver.moduleOutputInfo.name, "Wibble")
564558
}
@@ -2750,20 +2744,11 @@ final class SwiftDriverTests: XCTestCase {
27502744
do {
27512745
var driver = try Driver(args: ["swift"], env: envWithFakeSwiftHelp)
27522746
let plannedJobs = try driver.planBuild()
2753-
XCTAssertEqual(plannedJobs.count, 3)
2754-
2755-
let versionJob = plannedJobs[0]
2756-
XCTAssertTrue(versionJob.tool.name.contains("swift"))
2757-
XCTAssertTrue(versionJob.commandLine.contains(.flag("--version")))
2747+
XCTAssertEqual(plannedJobs.count, 1)
27582748

2759-
let helpJob = plannedJobs[1]
2749+
let helpJob = plannedJobs[0]
27602750
XCTAssertTrue(helpJob.tool.name.contains("swift-help"))
27612751
XCTAssertTrue(helpJob.commandLine.contains(.flag("intro")))
2762-
2763-
let replJob = plannedJobs[2]
2764-
XCTAssertTrue(replJob.tool.name.contains("lldb"))
2765-
XCTAssertTrue(replJob.requiresInPlaceExecution)
2766-
XCTAssert(replJob.commandLine.contains(where: { isExpectedLLDBREPLFlag($0) }))
27672752
}
27682753

27692754
do {

0 commit comments

Comments
 (0)