@@ -57,7 +57,34 @@ class Driver {
5757 }
5858
5959 val fileNames = CompilerCommand .checkUsage(summary, sourcesRequired)(ctx)
60- (fileNames, ctx)
60+ fromTastySetup(fileNames, ctx)
61+ }
62+
63+ /** Setup extra classpath and figure out class names for tasty file inputs */
64+ private def fromTastySetup (fileNames0 : List [String ], ctx0 : Context ) = {
65+ if (ctx0.settings.fromTasty.value(ctx0)) {
66+ // Resolve classpath and class names of tasty files
67+ val (classPaths, classNames) = fileNames0.map { name =>
68+ val path = Paths .get(name)
69+ if (! name.endsWith(" .tasty" )) (" " , name)
70+ else if (Files .exists(path)) {
71+ TastyFileUtil .getClassName(path) match {
72+ case Some (res) => res
73+ case _ =>
74+ ctx0.error(s " Could not load classname from $name. " )
75+ (" " , name)
76+ }
77+ } else {
78+ ctx0.error(s " File $name does not exist. " )
79+ (" " , name)
80+ }
81+ }.unzip
82+ val ctx1 = ctx0.fresh
83+ val classPaths1 = classPaths.distinct.filter(_ != " " )
84+ val fullClassPath = (classPaths1 :+ ctx1.settings.classpath.value(ctx1)).mkString(java.io.File .pathSeparator)
85+ ctx1.setSetting(ctx1.settings.classpath, fullClassPath)
86+ (classNames, ctx1)
87+ } else (fileNames0, ctx0)
6188 }
6289
6390 /** Entry point to the compiler that can be conveniently used with Java reflection.
@@ -135,31 +162,7 @@ class Driver {
135162 * if compilation succeeded.
136163 */
137164 def process (args : Array [String ], rootCtx : Context ): Reporter = {
138- val (fileNames0, ctx0) = setup(args, rootCtx)
139- val (fileNames, ctx) =
140- if (ctx0.settings.fromTasty.value(ctx0)) {
141- // Resolve classpath and class names of tasty files
142- val (classPaths, classNames) = fileNames0.map { name =>
143- val path = Paths .get(name)
144- if (! name.endsWith(" .tasty" )) (" " , name)
145- else if (Files .exists(path)) {
146- TastyFileUtil .getClassName(path) match {
147- case Some (res) => res
148- case _ =>
149- ctx0.error(s " Could not load classname from $name. " )
150- (" " , name)
151- }
152- } else {
153- ctx0.error(s " File $name does not exist. " )
154- (" " , name)
155- }
156- }.unzip
157- val ctx1 = ctx0.fresh
158- val classPaths1 = classPaths.distinct.filter(_ != " " )
159- val fullClassPath = (ctx1.settings.classpath.value(ctx1) :: classPaths1).mkString(java.io.File .pathSeparator)
160- ctx1.setSetting(ctx1.settings.classpath, fullClassPath)
161- (classNames, ctx1)
162- } else (fileNames0, ctx0)
165+ val (fileNames, ctx) = setup(args, rootCtx)
163166 doCompile(newCompiler(ctx), fileNames)(ctx)
164167 }
165168
0 commit comments