@@ -32,10 +32,15 @@ import dotty.tools.dotc.reporting.Message
32
32
import dotty .tools .repl .AbstractFileClassLoader
33
33
34
34
/** Tree interpreter for metaprogramming constructs */
35
- class Interpreter (pos : SrcPos , classLoader : ClassLoader )(using Context ):
35
+ class Interpreter (pos : SrcPos , classLoader0 : ClassLoader )(using Context ):
36
36
import Interpreter ._
37
37
import tpd ._
38
38
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
+
39
44
/** Local variable environment */
40
45
type Env = Map [Symbol , Object ]
41
46
def emptyEnv : Env = Map .empty
@@ -157,18 +162,12 @@ class Interpreter(pos: SrcPos, classLoader: ClassLoader)(using Context):
157
162
args.toSeq
158
163
159
164
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)
168
167
catch
169
168
case MissingClassDefinedInCurrentRun (sym) =>
170
169
suspendOnMissing(sym, pos)
171
-
170
+ val clazz = inst.getClass
172
171
val name = fn.name.asTermName
173
172
val method = getMethod(clazz, name, paramsSig(fn))
174
173
stopIfRuntimeException(method.invoke(inst, args : _* ), method)
0 commit comments