Skip to content

Commit b9ec198

Browse files
committed
Runner sets residual args instead of append
1 parent c923db2 commit b9ec198

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,13 @@ object MainGenericRunner {
199199
Option.when(Jar.isJarOrZip(dotty.tools.io.Path(entryPath)))(Jar(entryPath).mainClass).flatten
200200
}.isDefined
201201
}
202-
targetToRun match
202+
val newSettings =
203+
targetToRun match
203204
case Some(fqName) =>
204-
run(settings.withTargetToRun(fqName).withResidualArgs(settings.residualArgs.filter { _ != fqName }*).withExecuteMode(ExecuteMode.Run))
205+
settings.withTargetToRun(fqName).copy(residualArgs = settings.residualArgs.filterNot(fqName.==)).withExecuteMode(ExecuteMode.Run)
205206
case None =>
206-
run(settings.withExecuteMode(ExecuteMode.Repl))
207+
settings.withExecuteMode(ExecuteMode.Repl)
208+
run(newSettings)
207209
case ExecuteMode.Run =>
208210
val scalaClasspath = ClasspathFromClassloader(Thread.currentThread().getContextClassLoader).split(classpathSeparator)
209211
val newClasspath = (settings.classPath.flatMap(_.split(classpathSeparator).filter(_.nonEmpty)) ++ removeCompiler(scalaClasspath) :+ ".").map(File(_).toURI.toURL)

tests/run-with-compiler/i14541.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world

tests/run-with-compiler/i14541.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
object Test:
3+
import dotty.tools.runner.RichClassLoader.*
4+
def main(args: Array[String]): Unit = getClass.getClassLoader.run("echo", List("hello", "world"))
5+
6+
@main def echo(args: String*): Unit = println {
7+
args.mkString(" ")
8+
}

0 commit comments

Comments
 (0)