@@ -94,7 +94,7 @@ class ReplDriver(settings: Array[String],
9494 initCtx.settings.YwithBestEffortTasty .name
9595 )
9696
97- private def setupRootCtx (settings : Array [String ], rootCtx : Context ) = {
97+ private def setupRootCtx (settings : Array [String ], rootCtx : Context , oldCP : Option [ AbstractFile ] = None ) = {
9898 val incompatible = settings.intersect(incompatibleOptions)
9999 val filteredSettings =
100100 if ! incompatible.isEmpty then
@@ -107,7 +107,7 @@ class ReplDriver(settings: Array[String],
107107 case Some ((files, ictx)) => inContext(ictx) {
108108 shouldStart = true
109109 if files.nonEmpty then out.println(i " Ignoring spurious arguments: $files%, % " )
110- ictx.base.initialize()
110+ ictx.base.initialize(oldCP )
111111 ictx
112112 }
113113 case None =>
@@ -537,7 +537,7 @@ class ReplDriver(settings: Array[String],
537537 val cp = state.context.platform.classPath(using state.context).asClassPathString
538538// println(s"CURRENT CP STRING: $cp")
539539 val newCP = s " $cp${JFile .pathSeparator}$path"
540- println(s " UPDATED CP: $newCP" )
540+ // println(s"UPDATED CP: $newCP")
541541
542542 // add to compiler class path
543543// println(s"INIT state classPath = ${state.context.platform.classPath(using state.context).asClassPathString}")
@@ -546,15 +546,37 @@ class ReplDriver(settings: Array[String],
546546// println(s"classPath after add = ${state.context.platform.classPath(using state.context).asClassPathString}")
547547
548548 // recreate initial context
549- resetToInitial(List (" -classpath" , newCP))
550- // rootCtx = setupRootCtx(Array(), rootCtx.fresh.setSetting(rootCtx.settings.classpath, newCP))
549+ // resetToInitial(List("-classpath", newCP))
550+ // rootCtx = initialCtx(List("-classpath", newCP))
551+
552+ // println(s"init@7 = ${initCtx.fresh.settings.allSettings(7).name}, value = ${initCtx.fresh.settingsState.value(7)}")
553+ // println(s"root@7 = ${rootCtx.fresh.settings.allSettings(7).name}, value = ${rootCtx.fresh.settingsState.value(7)}")
554+
555+ println(s " settings.outputDir.default = ${rootCtx.settings.outputDir.default}, settingsState.value= ${rootCtx.settingsState.value(7 )}, ? = ${rootCtx.settings.outputDir.valueIn(rootCtx.settingsState)}" )
556+ val oldOutputDir = rootCtx.settings.outputDir.valueIn(rootCtx.settingsState)
557+ val ctxToUse =
558+ initCtx.fresh
559+ .setSetting(rootCtx.settings.classpath, newCP)
560+ // .setSetting(rootCtx.settings.outputDir, oldOutputDir)
561+ // rootCtx.fresh
562+ // .setSetting(rootCtx.settings.classpath, newCP)
563+ // ctxToUse.platform.addToClassPath(ClassPathFactory.newClassPath(rootCtx.settings.outputDir.default)(using ctxToUse))
564+
565+ println(s " USED@7 = ${ctxToUse.settings.allSettings(7 ).name}, value = ${ctxToUse.settingsState.value(7 )}" )
566+ rootCtx = setupRootCtx(
567+ Array (),
568+ ctxToUse,
569+ oldCP = Some (oldOutputDir)
570+ )
551571 val s = state.copy(context = rootCtx)
572+ // println(s"VERIFY: ${s.context.platform.classPath(using s.context).hasPackage("mylibrary")}")
552573
553574 // new class loader
554575 val oldCL = rendering.classLoader()(using state.context)
555576 val newCL = fromURLsParallelCapable(s.context.platform.classPath(using s.context).asURLs, oldCL)
556- rendering.myClassLoader = new AbstractFileClassLoader (state.context.settings.outputDir.default, newCL)
557- // out.println(s"Added '$path' to classpath.")
577+ val innerCL = new AbstractFileClassLoader (oldOutputDir, newCL)
578+ rendering.myClassLoader = new AbstractFileClassLoader (s.context.settings.outputDir.default, innerCL)
579+ out.println(s " Added ' $path' to classpath. " )
558580 s
559581 case TypeOf (expr) =>
560582 expr match {
0 commit comments