@@ -94,7 +94,7 @@ class ReplDriver(settings: Array[String],
94
94
initCtx.settings.YwithBestEffortTasty .name
95
95
)
96
96
97
- private def setupRootCtx (settings : Array [String ], rootCtx : Context ) = {
97
+ private def setupRootCtx (settings : Array [String ], rootCtx : Context , oldCP : Option [ AbstractFile ] = None ) = {
98
98
val incompatible = settings.intersect(incompatibleOptions)
99
99
val filteredSettings =
100
100
if ! incompatible.isEmpty then
@@ -107,7 +107,7 @@ class ReplDriver(settings: Array[String],
107
107
case Some ((files, ictx)) => inContext(ictx) {
108
108
shouldStart = true
109
109
if files.nonEmpty then out.println(i " Ignoring spurious arguments: $files%, % " )
110
- ictx.base.initialize()
110
+ ictx.base.initialize(oldCP )
111
111
ictx
112
112
}
113
113
case None =>
@@ -537,7 +537,7 @@ class ReplDriver(settings: Array[String],
537
537
val cp = state.context.platform.classPath(using state.context).asClassPathString
538
538
// println(s"CURRENT CP STRING: $cp")
539
539
val newCP = s " $cp${JFile .pathSeparator}$path"
540
- println(s " UPDATED CP: $newCP" )
540
+ // println(s"UPDATED CP: $newCP")
541
541
542
542
// add to compiler class path
543
543
// println(s"INIT state classPath = ${state.context.platform.classPath(using state.context).asClassPathString}")
@@ -546,15 +546,37 @@ class ReplDriver(settings: Array[String],
546
546
// println(s"classPath after add = ${state.context.platform.classPath(using state.context).asClassPathString}")
547
547
548
548
// 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
+ )
551
571
val s = state.copy(context = rootCtx)
572
+ // println(s"VERIFY: ${s.context.platform.classPath(using s.context).hasPackage("mylibrary")}")
552
573
553
574
// new class loader
554
575
val oldCL = rendering.classLoader()(using state.context)
555
576
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. " )
558
580
s
559
581
case TypeOf (expr) =>
560
582
expr match {
0 commit comments