@@ -537,21 +537,23 @@ class ReplDriver(settings: Array[String],
537537 val existingClass = entries.filter(_.ext.isClass).map(classNameOf).find(alreadyDefined)
538538 if (existingClass.nonEmpty)
539539 out.println(s " The path ' $f' cannot be loaded, it contains a classfile that already exists on the classpath: ${existingClass.get}" )
540+ state
540541 else
541- // val cp = state.context.platform.classPath(using state.context).asClassPathString
542+ val cp = state.context.platform.classPath(using state.context).asClassPathString
542543// println(s"CURRENT CP STRING: $cp")
543- // val newCP = s"$cp${JFile.pathSeparator}$path"
544- // println(s"UPDATED CP: $newCP")
544+ val newCP = s " $cp${JFile .pathSeparator}$path"
545+ println(s " UPDATED CP: $newCP" )
545546
546547 // add to compiler class path
547- println(s " INIT state classPath = ${state.context.platform.classPath(using state.context).asClassPathString}" )
548- val cpCP = ClassPathFactory .newClassPath(jarFile)(using state.context)
549- state.context.platform.addToClassPath(cpCP)
550- println(s " classPath after add = ${state.context.platform.classPath(using state.context).asClassPathString}" )
548+ // println(s"INIT state classPath = ${state.context.platform.classPath(using state.context).asClassPathString}")
549+ // val cpCP = ClassPathFactory.newClassPath(jarFile)(using state.context)
550+ // state.context.platform.addToClassPath(cpCP)
551+ // println(s"classPath after add = ${state.context.platform.classPath(using state.context).asClassPathString}")
551552
552- // create initial context
553- rootCtx = setupRootCtx(Array (), rootCtx)
554- state.copy(context = rootCtx)
553+ // recreate initial context
554+ rootCtx = setupRootCtx(Array (), rootCtx.fresh.setSetting(rootCtx.settings.classpath, newCP))
555+ val s = state.copy(context = rootCtx)
556+ println(s " after setupRootCtx classPath = ${s.context.platform.classPath(using s.context).asClassPathString}" )
555557
556558
557559 // new class loader
@@ -562,13 +564,11 @@ class ReplDriver(settings: Array[String],
562564// println(s"\nclass name = ${cpCP.className}")
563565// rendering.myClassLoader = new AbstractFileClassLoader(state.context.settings.outputDir.default, newCL)
564566// out.println(s"Added '$path' to classpath.")
565- println(s " after setupRootCtx classPath = ${state.context.platform.classPath(using state.context).asClassPathString}" )
566- state
567+ s
567568
568569 case KindOf (expr) =>
569570 out.println(s """ The :kind command is not currently supported. """ )
570571 state
571-
572572 case TypeOf (expr) =>
573573 expr match {
574574 case " " => out.println(s " :type <expression> " )
0 commit comments