Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build more: ImplicitConverter has been renamed Conversion #5819

Merged
merged 2 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/test-resources/repl/i5345
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scala> def x[A, B]: ImplicitConverter[A, B] = _ => ???
def x[A, B] => ImplicitConverter[A, B]
scala> def x[A, B]: Conversion[A, B] = _ => ???
def x[A, B] => Conversion[A, B]
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ 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)
}
}
Traverser.traverseTree(root)(reflect.rootContext)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -213,4 +213,4 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
case _ => None
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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"
}
}