@@ -32,10 +32,15 @@ import dotty.tools.dotc.reporting.Message
3232import dotty .tools .repl .AbstractFileClassLoader
3333
3434/** Tree interpreter for metaprogramming constructs */
35- class Interpreter (pos : SrcPos , classLoader : ClassLoader )(using Context ):
35+ class Interpreter (pos : SrcPos , classLoader0 : ClassLoader )(using Context ):
3636 import Interpreter ._
3737 import tpd ._
3838
39+ val classLoader =
40+ if ctx.owner.topLevelClass.name.startsWith(str.REPL_SESSION_LINE ) then
41+ new AbstractFileClassLoader (ctx.settings.outputDir.value, classLoader0)
42+ else classLoader0
43+
3944 /** Local variable environment */
4045 type Env = Map [Symbol , Object ]
4146 def emptyEnv : Env = Map .empty
@@ -157,18 +162,12 @@ class Interpreter(pos: SrcPos, classLoader: ClassLoader)(using Context):
157162 args.toSeq
158163
159164 private def interpretedStaticMethodCall (moduleClass : Symbol , fn : Symbol , args : List [Object ]): Object = {
160- val (inst, clazz) =
161- try
162- if (moduleClass.name.startsWith(str.REPL_SESSION_LINE ))
163- (null , loadReplLineClass(moduleClass))
164- else {
165- val inst = loadModule(moduleClass)
166- (inst, inst.getClass)
167- }
165+ val inst =
166+ try loadModule(moduleClass)
168167 catch
169168 case MissingClassDefinedInCurrentRun (sym) =>
170169 suspendOnMissing(sym, pos)
171-
170+ val clazz = inst.getClass
172171 val name = fn.name.asTermName
173172 val method = getMethod(clazz, name, paramsSig(fn))
174173 stopIfRuntimeException(method.invoke(inst, args : _* ), method)
0 commit comments