You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I seem to have found a bug in scala-reflect - when invoking apply on a MethodMirror, I end up getting a null where I have supplied a non-null value.
Here is some sample code. You can see I get a null where I should get a B(7):
// Test.scala
object Test extends App {
object a {
case class B(i: Int)
implicit class C(val i: Int) extends AnyVal
case class D(b: B, c: C)
}
import a._
import scala.reflect.runtime.currentMirror
import scala.reflect.runtime.universe._
val tpe = typeOf[D]
val classSymbol: ClassSymbol = tpe.typeSymbol.asClass
val moduleSymbol: ModuleSymbol = classSymbol.companion.asModule
val moduleMirror: ModuleMirror = currentMirror.reflectModule(moduleSymbol)
val moduleInstance: Any = moduleMirror.instance
val instanceMirror = currentMirror.reflect(moduleInstance)
val typeSignature = instanceMirror.symbol.typeSignature
val applyMethod = typeSignature.member(TermName("apply")).asMethod
val applyMirror = instanceMirror.reflectMethod(applyMethod)
val applyResult = applyMirror(B(7), new C(8))
println(applyResult)
// output is D(null,Test$a$C@8)
// the null seems to be due to a fall-through at line 433 of JavaMirrors.scala
}
This seems to happen whenever I have a MethodMirror with both implicit and non-implicit parameters. I am not very familiar with this code, but to me it seems like an else args1\(i\) = arg is missing just below line 433 of JavaMirrors.scala.
This test was run against Scala 2.11.5, but I got the same results against 2.11.2, 2.11.3, and 2.11.4. I tried against 2.10 as well, but the API has changed a lot and I would have had to refactor to get it to compile there.
The text was updated successfully, but these errors were encountered:
I seem to have found a bug in scala-reflect - when invoking apply on a
MethodMirror
, I end up getting a null where I have supplied a non-null value.Here is some sample code. You can see I get a
null
where I should get aB(7)
:This seems to happen whenever I have a MethodMirror with both implicit and non-implicit parameters. I am not very familiar with this code, but to me it seems like an
else args1\(i\) = arg
is missing just below line 433 of JavaMirrors.scala.This test was run against Scala 2.11.5, but I got the same results against 2.11.2, 2.11.3, and 2.11.4. I tried against 2.10 as well, but the API has changed a lot and I would have had to refactor to get it to compile there.
The text was updated successfully, but these errors were encountered: