diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala index 9eaf6c02dc9d..ba0c87ce5191 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala @@ -14,7 +14,7 @@ class TastyInterpreter extends TastyConsumer { case DefDef("main", _, _, _, Some(rhs)) => val interpreter = new jvm.Interpreter(reflect) - interpreter.eval(rhs)(Map.empty) + interpreter.eval(rhs) with Map.empty // TODO: recurse only for PackageDef, ClassDef case tree => super.traverseTree(tree) @@ -22,4 +22,4 @@ class TastyInterpreter extends TastyConsumer { } Traverser.traverseTree(root)(reflect.rootContext) } -} \ No newline at end of file +} diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index 8df8d08d65b2..3ce4283ff4f6 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -13,19 +13,19 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { /** Representation of objects and values in the interpreter */ type AbstractAny - type Result = implicit Env => AbstractAny + type Result = Env |=> AbstractAny def localValue(sym: Symbol)(implicit env: Env): LocalValue = env(sym) - def withLocalValue[T](sym: Symbol, value: LocalValue)(in: implicit Env => T)(implicit env: Env): T = - in(env.updated(sym, value)) + def withLocalValue[T](sym: Symbol, value: LocalValue)(in: Env |=> T)(implicit env: Env): T = + in with env.updated(sym, value) - def withLocalValues[T](syms: List[Symbol], values: List[LocalValue])(in: implicit Env => T)(implicit env: Env): T = - in(env ++ syms.zip(values)) + def withLocalValues[T](syms: List[Symbol], values: List[LocalValue])(in: Env |=> T)(implicit env: Env): T = + in with (env ++ syms.zip(values)) - def interpretCall(instance: AbstractAny, sym: DefSymbol, args: List[AbstractAny]): Result = { + def interpretCall(inst: AbstractAny, sym: DefSymbol, args: List[AbstractAny]): Result = { // TODO - // withLocalValue(`this`, instance) { + // withLocalValue(`this`, inst) { val syms = sym.tree.paramss.headOption.getOrElse(Nil).map(_.symbol) withLocalValues(syms, args.map(LocalValue.valFrom(_))) { eval(sym.tree.rhs.get) @@ -65,7 +65,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { def interpretBlock(stats: List[Statement], expr: Term): Result = { val newEnv = stats.foldLeft(implicitly[Env])((accEnv, stat) => stat match { case ValDef(name, tpt, Some(rhs)) => - def evalRhs = eval(rhs)(accEnv) + def evalRhs = eval(rhs) with accEnv val evalRef: LocalValue = if (stat.symbol.flags.is(Flags.Lazy)) LocalValue.lazyValFrom(evalRhs) else if (stat.symbol.flags.is(Flags.Mutable)) LocalValue.varFrom(evalRhs) @@ -76,10 +76,10 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { // TODO: record the environment for closure purposes accEnv case stat => - eval(stat)(accEnv) + eval(stat) with accEnv accEnv }) - eval(expr)(newEnv) + eval(expr) with newEnv } def interpretUnit(): AbstractAny @@ -213,4 +213,4 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { case _ => None } } -} \ No newline at end of file +} diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala index 3983dd298113..a18d76ea208f 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala @@ -47,22 +47,22 @@ class JVMReflection[R <: Reflection & Singleton](val reflect: R) { } def interpretStaticVal(moduleClass: Symbol, fn: Symbol): Object = { - val instance = loadModule(moduleClass) + val inst = loadModule(moduleClass) val name = fn.name - val method = getMethod(instance.getClass, name, Nil) - method.invoke(instance) + val method = getMethod(inst.getClass, name, Nil) + method.invoke(inst) } def interpretStaticMethodCall(moduleClass: Symbol, fn: Symbol, args: List[Object]): Object = { // TODO can we use interpretMethodCall instead? - val instance = loadModule(moduleClass) - val method = getMethod(instance.getClass, fn.name, paramsSig(fn)) - method.invoke(instance, args: _*) + val inst = loadModule(moduleClass) + val method = getMethod(inst.getClass, fn.name, paramsSig(fn)) + method.invoke(inst, args: _*) } - def interpretMethodCall(instance: Object, fn: Symbol, args: List[Object]): Object = { - val method = getMethod(instance.getClass, fn.name, paramsSig(fn)) - method.invoke(instance, args: _*) + def interpretMethodCall(inst: Object, fn: Symbol, args: List[Object]): Object = { + val method = getMethod(inst.getClass, fn.name, paramsSig(fn)) + method.invoke(inst, args: _*) } def interpretNew(fn: Symbol, args: List[Object]): Object = { @@ -113,4 +113,4 @@ class JVMReflection[R <: Reflection & Singleton](val reflect: R) { } private def extraMsg = ". The most common reason for that is that you apply macros in the compilation run that defines them" -} \ No newline at end of file +}