Skip to content

Commit 08a9a55

Browse files
committed
updated state with classpath
1 parent cbf7f8f commit 08a9a55

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -532,21 +532,23 @@ class ReplDriver(settings: Array[String],
532532
val existingClass = entries.filter(_.ext.isClass).map(classNameOf).find(alreadyDefined)
533533
if (existingClass.nonEmpty)
534534
out.println(s"The path '$f' cannot be loaded, it contains a classfile that already exists on the classpath: ${existingClass.get}")
535+
state
535536
else
536-
// val cp = state.context.platform.classPath(using state.context).asClassPathString
537+
val cp = state.context.platform.classPath(using state.context).asClassPathString
537538
// println(s"CURRENT CP STRING: $cp")
538-
// val newCP = s"$cp${JFile.pathSeparator}$path"
539-
// println(s"UPDATED CP: $newCP")
539+
val newCP = s"$cp${JFile.pathSeparator}$path"
540+
println(s"UPDATED CP: $newCP")
540541

541542
// add to compiler class path
542-
println(s"INIT state classPath = ${state.context.platform.classPath(using state.context).asClassPathString}")
543-
val cpCP = ClassPathFactory.newClassPath(jarFile)(using state.context)
544-
state.context.platform.addToClassPath(cpCP)
545-
println(s"classPath after add = ${state.context.platform.classPath(using state.context).asClassPathString}")
543+
// println(s"INIT state classPath = ${state.context.platform.classPath(using state.context).asClassPathString}")
544+
// val cpCP = ClassPathFactory.newClassPath(jarFile)(using state.context)
545+
// state.context.platform.addToClassPath(cpCP)
546+
// println(s"classPath after add = ${state.context.platform.classPath(using state.context).asClassPathString}")
546547

547-
// create initial context
548-
rootCtx = setupRootCtx(Array(), rootCtx)
549-
state.copy(context = rootCtx)
548+
// recreate initial context
549+
rootCtx = setupRootCtx(Array(), rootCtx.fresh.setSetting(rootCtx.settings.classpath, newCP))
550+
val s = state.copy(context = rootCtx)
551+
println(s"after setupRootCtx classPath = ${s.context.platform.classPath(using s.context).asClassPathString}")
550552

551553

552554
// new class loader
@@ -557,9 +559,7 @@ class ReplDriver(settings: Array[String],
557559
// println(s"\nclass name = ${cpCP.className}")
558560
// rendering.myClassLoader = new AbstractFileClassLoader(state.context.settings.outputDir.default, newCL)
559561
// out.println(s"Added '$path' to classpath.")
560-
println(s"after setupRootCtx classPath = ${state.context.platform.classPath(using state.context).asClassPathString}")
561-
state
562-
562+
s
563563
case TypeOf(expr) =>
564564
expr match {
565565
case "" => out.println(s":type <expression>")

0 commit comments

Comments
 (0)