[scala-reflect] arguments get replaced with null in MethodMirror.apply when there are both implicit and non-implicit parameters

John Sullivan <[email protected]>
Newsgroups gmane.comp.lang.scala,gmane.spam.detected
Message-ID <[email protected]>
Good morning everyone and happy MLK day!

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):

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 familiar with this code at all, 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.

If you like I can submit a bug report.

Thanks! -John

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.