From c92d0d6e07006e7ceca1347c8b42e52e8540804e Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Tue, 22 Feb 2022 12:14:53 -0800 Subject: [PATCH] Runner sets residual args instead of append --- compiler/src/dotty/tools/MainGenericRunner.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/MainGenericRunner.scala b/compiler/src/dotty/tools/MainGenericRunner.scala index bcaa00b02133..30baf78c922e 100644 --- a/compiler/src/dotty/tools/MainGenericRunner.scala +++ b/compiler/src/dotty/tools/MainGenericRunner.scala @@ -199,11 +199,13 @@ object MainGenericRunner { Option.when(Jar.isJarOrZip(dotty.tools.io.Path(entryPath)))(Jar(entryPath).mainClass).flatten }.isDefined } - targetToRun match + val newSettings = + targetToRun match case Some(fqName) => - run(settings.withTargetToRun(fqName).withResidualArgs(settings.residualArgs.filter { _ != fqName }*).withExecuteMode(ExecuteMode.Run)) + settings.withTargetToRun(fqName).copy(residualArgs = settings.residualArgs.filterNot(fqName.==)).withExecuteMode(ExecuteMode.Run) case None => - run(settings.withExecuteMode(ExecuteMode.Repl)) + settings.withExecuteMode(ExecuteMode.Repl) + run(newSettings) case ExecuteMode.Run => val scalaClasspath = ClasspathFromClassloader(Thread.currentThread().getContextClassLoader).split(classpathSeparator) val newClasspath = (settings.classPath.flatMap(_.split(classpathSeparator).filter(_.nonEmpty)) ++ removeCompiler(scalaClasspath) :+ ".").map(File(_).toURI.toURL)