Skip to content

Commit 5964e04

Browse files
committed
Address reviewer feedback
1 parent 086815b commit 5964e04

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class CompilationTests extends ParallelTesting {
197197
compileDir("../compiler/src/dotty/tools/dotc/config", picklingOptions) +
198198
compileDir("../compiler/src/dotty/tools/dotc/parsing", picklingOptions) +
199199
compileDir("../compiler/src/dotty/tools/dotc/printing", picklingOptions) +
200+
compileDir("../repl/src/dotty/tools/repl", picklingOptions) +
200201
compileDir("../compiler/src/dotty/tools/dotc/rewrite", picklingOptions) +
201202
compileDir("../compiler/src/dotty/tools/dotc/transform", picklingOptions) +
202203
compileDir("../compiler/src/dotty/tools/dotc/typer", picklingOptions) +

repl/src/dotty/tools/repl/ParseResult.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ case object Help extends Command {
8484
val text =
8585
"""The REPL has several commands available:
8686
|
87-
|:help print this summary or command-specific help
87+
|:help print this summary
8888
|:load <path> interpret lines in a file
8989
|:quit exit the interpreter
9090
|:type <expression> evaluate the type of the given expression
91+
|:imports show import history
9192
|:reset reset the repl to its initial state, forgetting all session entries
9293
""".stripMargin
9394
}

repl/src/dotty/tools/repl/Rendering.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ private[repl] class Rendering(compiler: ReplCompiler,
5252

5353
val res =
5454
resObj
55-
.getDeclaredMethods.find(_.getName == sym.name.toString + "Show").get
56-
.invoke(null).toString
55+
.getDeclaredMethods.find(_.getName == sym.name.toString + "Show").get
56+
.invoke(null).toString
5757

5858
if (!sym.is(Flags.Method) && sym.info == defn.UnitType)
5959
None

repl/src/dotty/tools/repl/ReplCompiler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ class ReplCompiler(val directory: AbstractFile) extends Compiler {
155155
val tmpl = Template(emptyConstructor(ctx), Nil, EmptyValDef, defs.stats)
156156
List(
157157
ModuleDef(objectName(defs.state), tmpl)
158-
.withMods(new Modifiers(Module | Final))
159-
.withPos(Position(defs.stats.head.pos.start, defs.stats.last.pos.end))
158+
.withMods(new Modifiers(Module | Final))
159+
.withPos(Position(defs.stats.head.pos.start, defs.stats.last.pos.end))
160160
)
161161
}
162162

repl/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class ReplDriver(settings: Array[String],
299299
private def interpretCommand(cmd: Command)(implicit state: State): State = cmd match {
300300
case UnknownCommand(cmd) => {
301301
out.println(s"""Unknown command: "$cmd", run ":help" for a list of commands""")
302-
state.withHistory(s":$cmd")
302+
state.withHistory(s"$cmd")
303303
}
304304

305305
case Help => {
@@ -319,7 +319,8 @@ class ReplDriver(settings: Array[String],
319319

320320
case Load(path) =>
321321
val loadCmd = s"${Load.command} $path"
322-
if ((new java.io.File(path)).exists) {
322+
val file = new java.io.File(path)
323+
if (file.exists) {
323324
val contents = scala.io.Source.fromFile(path).mkString
324325
ParseResult(contents)(state.run.runContext) match {
325326
case parsed: Parsed =>
@@ -331,7 +332,7 @@ class ReplDriver(settings: Array[String],
331332
}
332333
}
333334
else {
334-
out.println(s"""Couldn't find file "$path"""")
335+
out.println(s"""Couldn't find file "${file.getCanonicalPath}"""")
335336
state.withHistory(loadCmd)
336337
}
337338

repl/src/dotty/tools/repl/package.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ package object repl {
1717
new StoreReporter(null)
1818
with UniqueMessagePositions with HideNonSensicalMessages
1919

20-
private[repl] implicit class ListOps[A](val xs: List[A]) extends AnyVal {
21-
def intersperse(a: A): List[A] = {
22-
def recur(xs: List[A]): List[A] = xs match {
23-
case x :: Nil => List(x)
24-
case xs => List(xs.head, a) ++ recur(xs.tail)
25-
}
26-
recur(xs)
27-
}
20+
private[repl] implicit class ListOps[A](val nel: List[A]) extends AnyVal {
21+
def intersperse(a: A): List[A] =
22+
nel.flatMap(a :: _ :: Nil).tail
2823
}
2924

3025
private[repl] implicit class ShowUser(val s: Symbol) extends AnyVal {

repl/test/dotty/tools/repl/ScriptedTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.io.Source
1111

1212
import dotc.reporting.MessageRendering
1313

14-
/** Runs all tests contained withing `/repl/test-resources/scripts` */
14+
/** Runs all tests contained in `/repl/test-resources/scripts` */
1515
class ScriptedTests extends ReplTest with MessageRendering {
1616

1717
private def scripts(path: String): Array[JFile] = {

0 commit comments

Comments
 (0)